Sandbox API Key doesn't work with swagger page
Monday, March 1, 2021 at 01:22pmHi,
I tried using the API Key (specified under the Authorize button) from under the sandbox account (not the Client ID & Secret) with the swagger page (https://community.onespan.com/products/onespan-sign/sandbox#/) where different calls can be tried out. However, the API key is not accepted. This is the response:
{ "messageKey": "error.unauthorised.noSession", "message": "Failed to retrieve Session", "code": 401, "name": "Unauthorized" }
Is there anything additional that needs to be done to use the swagger page?
Thanks in advance.
Reply to: Sandbox API Key doesn't work with swagger page
Monday, March 1, 2021 at 02:27pmHi IlyaS,
Have you entered it completely like "Basic {your_api_key}" vs only input the API Key?
Another underlying cause is the swagger page only connects to the US2 sandbox environment (https://sandbox.esignlive.com), so it won't work if your account is in other environments and you'd download the YAML file, edit it then load it in another swagger editor.
Duo
Reply to: Hi IlyaS, Have you…
Monday, March 1, 2021 at 05:14pmHi Duo,
The environment is: https://sandbox.e-signlive.ca/ . I guess for Canadian sandbox it wouldn't work? The only way to test then is by calling direct via a REST client or from code?
Thanks,
Ilya
Reply to: Hi Duo, The environment…
Monday, March 1, 2021 at 06:33pmHi Ilya,
Yeah, currently it only supports the US2 sandbox. And an API testing tool like Postman or SoapUI could come in handy before actually implementing with code.
Duo
Reply to: Hi Ilya, Yeah, currently…
Tuesday, March 2, 2021 at 07:35amThanks Duo. Will try with Postman.
Regards,
Ilya
Reply to: Sandbox API Key doesn't work with swagger page
Tuesday, March 2, 2021 at 08:26amHi Duo,
I tried getting the authentication token via Postman using the client ID and secret, but it doesn't seem to be working. Is there anything that I need to set differently (please see attached screenshot)?
Thanks in advance,
Ilya
Reply to: Sandbox API Key doesn't work with swagger page
Tuesday, March 2, 2021 at 08:44amHi Ilya,
I'm afraid it won't work in this way, this is because the API OneSpan Sign exposed to generate access token doesn't restrictly fit the Client Credentials Flow, see below:
HTTP Request
POST /apitoken/clientApp/accessToken
HTTP Headers
Accept: application/json Content-Type: application/json
Request Payload
{ "clientId": "your_client_id", "secret": "your_client_secret", "type": "OWNER" }
The request body has to be JSON format, instead of the typical "application/x-www-form-urlencoded"
You can add a separate request hitting above endpoint. Then specify the bearer header as the authorization method for any subsequent API calls.
Duo
Reply to: Hi Ilya, I'm afraid it…
Tuesday, March 2, 2021 at 11:39amThanks Duo, I was able to get the Authorization Token via the client/secret request.
When trying to use it, however, I get no session error:
{
"code": 401,
"messageKey": "error.unauthorised.noSession",
"message": "Failed to retrieve Session",
"name": "Unauthorized"
}
I don't think I need a body to retrieve packages, but then that would be a different error anyway.
Thanks again.
Ilya
Reply to: Thanks Duo, I was able to…
Tuesday, March 2, 2021 at 11:59amHi Ilya,
Should it be sandbox.e-signlive.ca vs apps.e-signlive.ca?
Duo
Reply to: Hi Ilya, Should it be…
Tuesday, March 2, 2021 at 12:19pmHi Duo,
Tried it (https://sandbox.e-signlive.ca/api/packages/), but I get the same error.
{
"messageKey": "error.unauthorised.noSession",
"message": "Failed to retrieve Session",
"code": 401,
"name": "Unauthorized"
}
Regards,
Ilya
Reply to: Hi Duo, Tried it (https:…
Tuesday, March 2, 2021 at 12:26pmDo you mind having a quick try with my access token in CA sandbox? - 177f42f3ce102df3809cb1000f9900
Duo
Reply to: Do you mind having a quick…
Tuesday, March 2, 2021 at 12:53pmHmmm, yours works, and the only thing I changed was the token.
I just retrieved another token on my sandbox, and it started working too. I don't know why the first one did not work, I have not changed anything.
Thanks Duo regardless.
Ilya
Reply to: Hi Ilya, I'm afraid it…
Wednesday, March 3, 2021 at 09:58amHello Duo,
Is there documentation on the path 'apitoken/clientApp/accessToken'?
The only reference to 'apitoken/clientApp/accessToken' in the swagger file doesn't reference the required body.
I would've expected to find it in one of the following links, but it wasn't present:
Integration | OneSpan Community Platform
OneSpan Sign Sandbox | OneSpan Community Platform
Thanks,
Kevin
Reply to: Hello Duo, Is there…
Wednesday, March 3, 2021 at 10:00amHi Kevin,
I described this API endpoint in one of my blogs:
OneSpan Sign Release 11.34: API Token for Client Application
HTTP Request
POST /apitoken/clientApp/accessToken
HTTP Headers
Accept: application/json Content-Type: application/json
Request Payload
{ "clientId": "your_client_id", "secret": "your_client_secret", "type": "OWNER" }
The available options for the field “type” are “OWNER” and “SENDER”. If the latter, “email” field is required:
{ "clientId": " your_client_id ", "secret": " your_client_secret ", "type": "SENDER", "email": "sender_email" }
Duo
Reply to: Sandbox API Key doesn't work with swagger page
Wednesday, March 3, 2021 at 10:03amThat is exactly what I was after, thank you!