Using dptool to experiment with Dataporten API Gatekeeper

Ensure that you are running dptool version >= 1.8.

Register a client using Dataporten Dashboard, and add http://127.0.0.1:12012/callback as a valid redirect_uri.

Configure your client with dptool with a specific configuration name, in this case jwt.

dptool --configset jwt configure f4f5416c-dbb8-49d2-baa1-5c61329dd9ae 88c57cb1-ff9a-4cc4-9b88-ebb59c52b916

Then authenticate:

dptool auth --configset jwt

Then get userinfo, just to verify that you got a token, and to see information about the current user:

dptool me --configset jwt
{
    "user": {
        "userid_sec": [],
        "userid": "9f70f418-3a75-4617-8375-883ab6c2b0af",
        "name": "Andreas Åkre Solberg",
        "profilephoto": "p:54f93233-8603-497d-9241-17a69e12e619"
    },
    "audience": "f4f5416c-dbb8-49d2-baa1-5c61329dd9ae"
}

Now, let’s attempt to contact a specific API gatekeeper using our token:

dptool --configset jwt gk tokenissuer /

Example output:

Contacting endpoint https://tokenissuer.dataporten-api.no/
{ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQtc2VjIjpbImZlaWRlOmFuZHJlYXNAdW5pbmV0dC5ubyJdLCJzY29wZXMiOm51bGwsImlhdCI6MTQ2MzczMjMwMCwiZXhwIjoxNDYzNzM5NTAwLCJhdWQiOiJmNGY1NDE2Yy1kYmI4LTQ5ZDItYmFhMS01YzYxMzI5ZGQ5YWUiLCJpc3MiOiJodHRwczovL2F1dGguZGF0YXBvcnRlbi5ubyIsInN1YiI6IjlmNzBmNDE4LTNhNzUtNDYxNy04Mzc1LTg4M2FiNmMyYjBhZiJ9.G8xALGHhWsURAFp2mQ0bAx9kbb25Kh_kV8eBI8-Y0vk' }

Leave a Reply