• Developers
  • get monetary-account-bank -> 404 item not found for PSD2 connection

Hi,

I am trying to do a get request to the monetary-account-bank endpoint, but it keeps returning 404 => the item your requested can not be found.

Steps I took before getting this error:

  1. get an installation token for my application
  2. register as a psd2 user
  3. register a device-server
  4. request a session-token

Then setting up oauth

  1. create oauth client
  2. register redirect_uri
  3. get client_id and client_secret

Then for a customer

  1. redirect to /auth endpoint to request access
  2. trade in the authorization_code for an access_token
  3. get new installation token for customer
  4. /device-server call with new installation token and customer access_token
  5. /session-server call with installation token of my app and access_token as { 'secret' => access_token }

So far, so good and the following is returned:

{
"Response": [
{
"Id": {
"id": 18523085
}
},
{
"Token": {
"id": 18523085,
"created": "2022-12-23 09:14:05.055679",
"updated": "2022-12-23 09:14:05.055679",
"token": "USERSESSIONTOKEN"
}
},
{
"UserApiKey": {
"id": 165980,
"created": "2022-12-23 09:14:00.845887",
"updated": "2022-12-23 09:14:00.845887",
"requested_by_user": {
"UserPaymentServiceProvider": {
"id": 165957,
"display_name": "somename PISP AISP",
"public_nick_name": null,
"avatar": {
"uuid": "78f93a9e-979d-400a-a398-c1826e600c3d",
"image": [
{
"attachment_public_uuid": "935aaaf4-518a-4a54-aca1-15c74d79c9a5",
"height": 1023,
"width": 1024,
"content_type": "image/png",
"urls": [
{
"type": null,
"url": null
}
]
}
],
"anchor_uuid": null,
"style": null
},
"session_timeout": 324000
}
},
"granted_by_user": {
"UserPerson": {
"id": 163119,
"display_name": "Lydia",
"public_nick_name": null,
"avatar": {
"uuid": "9debf55b-70b1-4d43-8d51-d6e7bd42fb5b",
"image": [
{
"attachment_public_uuid": "4b7e0d1d-9167-48ac-990a-70e342c87812",
"height": 126,
"width": 200,
"content_type": "image/jpeg",
"urls": [
{
"type": null,
"url": null
}
]
}
],
"anchor_uuid": null,
"style": null
},
"session_timeout": null
}
}
}
}
]
}

Then, I use the this response to get:
bunq_user_id = response['Response'][2]['UserApiKey']['id']
session_token = response ['Response'][1]['Token']['token']

And where I keep getting this error is when I try to make a call to /v1/user/bunq_user_id/monetary-account-bank with a header: `'X-Bunq-Client-Authentication' => session_token.

I am missing something? I seem to be using the correct bunq_user_id from what I understand from the docs and other answers on this forum.

    At the point in the process where I am creating a session_token for the user that has given consent, so endpoint /session-server, what do I use for the header X-Bunq-Client-Authentication? It seems most logical to use the installation token that I created while registering the customer, but that returns {"Error":[{"error_description":"Insufficient authentication."}]}. The documentation does not specify this so it is a guess.

    If I use the installation token that I created for my app, it does work. However, then I run into the issue that I described in my original post.

      @Bastiaan#273199 Hi,

      Yes, I have tried that, but with the same response unfortunately:

      response: {"Error":[{"error_description":"The item you requested could not be found.","error_description_translated":"The item you requested could not be found."}]}

        @Bastiaan#273199 also, for my application it is sufficient to just get accounts and related transactions as an AISP

          4 days later

          Someone has an update on this?

            @New-Crimson-Buffalo-3442439264#273200 @Lars-Indigo-Zebra#273283

            I've "played" with the Sandbox API today and I can't simulate this error.
            Are you sure that you are using id of "UserPerson" inside the "granted_by_user"-object, from the https://public-api.sandbox.bunq.com/v1/session-server endpoint response JSON?

            When I use this id for the request to /v1/user/{UserPerson_id}/monetary-account I get an overview of the monetary accounts.

              5 days later

              I did use the id of 'UserPerson' inside the 'granted_by_user'-object. The docs imply that the id of the UserApiKey-object itself should be used, so I've also tried that. But both result in the same error.

              Also just doing a GET request to /v1/user/{UserPerson_id} with either one of the ID's returns the same 404 error: {"Error":[{"error_description":"The item you requested could not be found.","error_description_translated": "The item you requested could not be found."}]}

                @New-Crimson-Buffalo-3442439264#273470
                That's strange..
                It's working fine here if I follow these steps:

                • Create a pseudo PSD2 certificate for the Sandbox API with openssl command, as described here:
                  https://github.com/basst85/bunq_psd2_example
                • I'm using the following PHP-script to generate the API context for PSD2 and save it to a config file:
                  https://gist.github.com/basst85/2d5304df8b63c0afecfaa72c41faf21c
                  (install bunq's sdk_php via composer before running script)
                • Use the same script to generate oAuth-client and return authorization URL.
                • I'm opening this authorization URL on an Android emulator (with the bunq Sandbox app installed) in Chrome.
                • Authorize the PSD2 provider via the bunq Sandbox app.
                  After authorization it returns to the OAUTH_REDIRECT_URI as configurered in the PHP-script.
                • The redirect URL contains an authorization token, exchange this for an access_token as described here:
                  https://beta.doc.bunq.com/basics/oauth
                  You can find the needed client_id and client_secret in oauth.conf, generated by the example PHP-script.
                • You can use the returned access_token as a normal API-key. Use this to create an authorized session with the user account:
                  https://beta.doc.bunq.com/basics/authentication
                • Use the "UserPerson"-id from the "granted_by_user"-object, that is returned in the https://public-api.sandbox.bunq.com/v1/session-server endpoint response.
                  Write a Reply...