Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
...
...
Table of Contents |
---|
How to execute an OAuth API Authentication
Info |
---|
To execute this procedure, you should first guarantee that the client service setup is completed (https://must.atlassian.net/wiki/spaces/SIGNSTASH/pages/688129/Getting+Started#Client-Service-Setup) |
In his walk through we will be referring to the following example, where the client service alias is PRT.505767457-PRT.111222333-e064c8c0-32ad-4dcf-9a76-f7542a5bae15 and the defined client service is test_123_Test_456_!!!
Image ModifiedSteps:
generate the base64 of the string relative to <client service alias>:<client service password>. In our example it would be PRT.505767457-PRT.111222333-e064c8c0-32ad-4dcf-9a76-f7542a5bae15:test_123_Test_456_!!! (please note the colon sign “:”).
Example using https://www.base64encode.org/ will produce the encoded base64 credential string UFJULjUwNTc2NzQ1Ny1QUlQuMTExMjIyMzMzLWUwNjRjOGMwLTMyYWQtNGRjZi05YTc2LWY3NTQyYTViYWUxNTp0ZXN0XzEyM19UZXN0XzQ1Nl8hISE=
...
- Image Added
Authenticate your client service with the base64 credential string
Example using curl command (linux command line https://curl.se/docs/manpage.html )
Code Block language bash # Input Command curl --insecure -v -X POST https://staging.must.digital/oauth2/authorization-server/oauth/token -d "grant_type=client_credentials" -H "Authorization: Basic UFJULjUwNTc2NzQ1Ny1QUlQuMTExMjIyMzMzLWUwNjRjOGMwLTMyYWQtNGRjZi05YTc2LWY3NTQyYTViYWUxNTp0ZXN0XzEyM19UZXN0XzQ1Nl8hISE=" # Output Response from service {"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOb24td3MiXSwic2NvcGUiOlsicmVhZCIsIndyaXRlIl0sImV4cCI6MTY1NjQyMTk4OCwianRpIjoiaU1IRWdrTUhySlc1MmVvdDZyaVlxN1gyUWdBIiwiY2xpZW50X2lkIjoiUFJULjUwNTc2NzQ1Ny1QUlQuMTExMjIyMzMzLWEwZjViOGIwLTk3OGUtNDUwMy04OTU4LTZmZTBjYzAyNmZhMCJ9.OfeSMcsHgnFak3fl1I31reu6f8evrVceYa_LA4YeJrsDkHJMiZfie0KnSflteWVYsTvydqteBZC7fd8mPxslIvzn20fwYvCp8OpnBCV0oYEnLuyfYbTmgJltHho7XenLTZXPa3WVQmvh7Jp9WJQWID7iH6qruZOX2iHBNLwNuLGr6R9jv9k7Vy78tjqjm0LlT6KUL41UehWr3hakMSUOlLk8PQIvmsm8MzzQBnFtPre3bsFxXbimg7s-EuzO4JxOFHO9cw2132kV1Q","token_type":"bearer","expires_in":86399,"scope":"read write","jti":"iMHEgkMHrJW52eot6rgA"}
Example using curl command (PowerShell command line)
Code Block language powershell # Input Command curl -Method Post -Uri "https://staging.must.digital/oauth2/authorization-server/oauth/token" -Headers @{ "Content-Type" = "application/x-www-form-urlencoded" "Authorization" = "Basic UFJULjUwNTc2NzQ1Ny1QUlQuMTExMjIyMzMzLWUwNjRjOGMwLTMyYWQtNGRjZi05YTc2LWY3NTQyYTViYWUxNTp0ZXN0XzEyM19UZXN0XzQ1Nl8hISE=" } -Body "grant_type=client_credentials" # Output Response from service {"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOb24td3MiXSwic2NvcGUiOlsicmVhZCIsIndyaXRlIl0sImV4cCI6MTY1NjQyMTk4OCwianRpIjoiaU1IRWdrTUhySlc1MmVvdDZyaVlxN1gyUWdBIiwiY2xpZW50X2lkIjoiUFJULjUwNTc2NzQ1Ny1QUlQuMTExMjIyMzMzLWEwZjViOGIwLTk3OGUtNDUwMy04OTU4LTZmZTBjYzAyNmZhMCJ9.OfeSMcsHgnFak3fl1I31reu6f8evrVceYa_LA4YeJrsDkHJMiZfie0KnSflteWVYsTvydqteBZC7fd8mPxslIvzn20fwYvCp8OpnBCV0oYEnLuyfYbTmgJltHho7XenLTZXPa3WVQmvh7Jp9WJQWID7iH6qruZOX2iHBNLwNuLGr6R9jv9k7Vy78tjqjm0LlT6KUL41UehWr3hakMSUOlLk8PQIvmsm8MzzQBnFtPre3bsFxXbimg7s-EuzO4JxOFHO9cw2132kV1Q","token_type":"bearer","expires_in":86399,"scope":"read write","jti":"iMHEgkMHrJW52eot6rgA"}
At this point you have successfully retrieved an access token to be used in the API business calls, and that will be expired in 86399 seconds (~24h)
Authenticating using Swagger UI
Instead of using the curl command for authenticating, this section describes the usage of Swagger UI available in https://must.atlassian.net/wiki/spaces/SIGNSTASH/pages/786720/Connecting+your+service#API-Definition-and-Examples .
Steps:
Access Swagger GUI Authentication API in staging environment (see location here https://must.atlassian.net/wiki/spaces/SIGNSTASH/pages/786720/Connecting+your+service#API-Definition-and-Examples)
Select option “Authorize”:
Image AddedInsert the client service alias and the defined client service secret and press “Authorize”. We’ll use the defined information stated in the beggining of this article.
Image AddedAccess the detail of /oauth/token API function, and select “Try it out” option.
Image AddedSelect “Execute” to perform a test call to authentication API.
Image AddedA response with a valid access token is returned from the authentication server.
Image Added