Retrieving Access Tokens

You can look up and retrieve an existing transfer token by specifying its tokenId. As shown in the example below, you can also get the token's complete payload and the associated signatures. Both of the latter are optional.

// fetch a token

public static Token getToken(Member member, String tokenId) {

    Token token = member.getTokenBlocking(tokenId);

 

    // get token payload

    TokenPayload payload = token.getPayload();

 

    // get signatures

    List<TokenSignature> signatures = token.getPayloadSignaturesList();

 

    return token;

}

 

Here's an example of the response you'll receive if you request the token payload:

{

    "accounts": [

        {

         "id": "a:8DbPteGnytmMbKXdnWTReeRB6cYWKXZ84JgLTBC7fKL4:5zKcENpV",

         "name": "N26 Main Checking",

         "bankId": "n26",

         "accountFeatures": {

         "supportsInformation": true,

         "supportsSendPayment": true,

         "supportsReceivePayment": true

         },

         "accountDetails": {

             "identifier": "N26 Main Checking",

             "type": "CHECKING",

             "status": "ACTIVE",

             "metadata": {

                 "clientId": "1"

             }

         }

       },

    {

      "id": "a:6hLu9jSeDpXV9cWafdQxvxVFgoptZX65hwVWPgzCBBGL:5zKcENpV",

      "name": "N26 Savings",

      "bankId": "n26",

      "accountFeatures": {

          "supportsInformation": true,

          "supportsSendPayment": true,

          "supportsReceivePayment": true

      },

      "accountDetails": {

          "identifier": "n26 Savings",

          "type": "CHECKING",

          "status": "ACTIVE",

          "metadata": {

              "clientId": "1"

          }

      }

    }

  ]

}

If you request signatures, you'll also receive this:

    "payloadSignatures": [{

        "action": "ENDORSED",

        "signature": {

            "memberId": "m:2YLns17mwhzbNYMofToaP34kFAYx:5zKtXEAq",

            "keyId": "EVknJb1X_wqpyVc8",

            "signature":

                "1fO5tXvfB27P4_lYgerjxTyYX1q-n-TUdTmn0w-awEBuG0ml-6jEhkQFQxnDFTzGHlYVodIaggtxegsSV60lCg"

            }

        },

        {

            "action": "ENDORSED",

            "signature": {

                "memberId": "m:36XFB8Cx257rJb265Fa5FAkrXN7M:5zKtXEAq",

                "keyId": "rki_qdKsD9al2BQf",

                "signature":

                    "EE3Zk5VF257RFKcWs0JxyrXnkOCXB3EagATzfOSA_q7eltqTq_mUIL-zP8jT2r-vmRPHd_3BBEVTQtxgFuhjDw"

             }

         }]

       },

       "status": "SUCCESS"

    }

}

Get a Paged List of Tokens

You can get a list of n tokens in order of the most recent, beginning at an offset, for which the TPP member was/is the grantee.

The following example returns a list with the ten most recent tokens and an offset that can be used to get the next ten. Calling this method again will generate the next ten tokens in the list, and so forth.

// returns a list of access tokens associated with the member

public static PagedList<Token, String> getAccessTokens(Member member) {

    // last 10 tokens and offset that can be used to get the next 10

    PagedList<Token, String> pagedList = member.getAccessTokensBlocking("", 10);

 

    return pagedList;

}

Next, we'll cover the method for canceling an access token.