Last Updated: 10/27/2021, 8:09:47 AM

# Getting Authorized In Swagger

Follow the steps below to get authorized in Swagger, so that you can test our API endpoints.

  1. In the Admin Portal, open the Platform Configurations menu in the top-right corner of the screen, and click OAuth Clients. Browse the list of clients to find the one you’d like to use to access the endpoints, and click View next to the client to open it. In the Client Details window, copy the Client ID. Make note of the namespace the client is located in as well; you’ll need this information later.

    getting-authorized-in-swagger

  2. Open the Swagger page for the service you want to access. You can find a list of each of our Swagger pages on our API endpoints page. When you’ve navigated to the desired Swagger page, click the green Authorize button in the top-right corner of the screen.

    getting-authorized-in-swagger

  3. The Available Authorizations window that appears contains two options: Authorization (APIKey) and Basic Authorization. Paste the Client ID from earlier into the Username box under Basic Authorization and click the Authorize button.

    getting-authorized-in-swagger

  4. Use the https://demo.accelbyte.io/iam/apidocs/#/OAuth/TokenGrant endpoint. Click Try Out Now and then do the following:

    • Select password as your grant_type
    • Input your username and password for the Admin Portal
    • Input the namespace that contains the client whose ID you used to authorize.

    When you’re done, click Execute. Upon successful request, your access token will be returned in the server response.

    getting-authorized-in-swagger

  5. Copy the contents of the access_token field in the server response. This will be a very long string, as seen in the image above.

  6. Return to the Available Authorizations window by clicking the green Authorize icon in the top-right corner of the Swagger page. In the Authorization (APIKey) section, type the word “Bearer” (must be capitalized), followed by one space, then paste your access token. Then, click Authorize.

    getting-authorized-in-swagger

  7. Finally, click Logout in the Basic Authorization section. Now you can test the API endpoints in Swagger.

# Get Authorized Using Curl

If you use curl, you can also get an access token for Swagger using the code below.

  1. Type the above code into command prompt:
    • Replace <<base_url>> with your base URL.
    • Replace <<client_credential>> with your OAuth Token in the format of client_id:client_secret, in base64 encoding.
    • Replace <<username>> with your username.
    • Replace <<password>> with your password.
    • Replace <<namespace>> with the namespace that you want to be authorized by, either your publisher or game namespace. Then hit Enter.

# Response

Here is an example response to a successful request:

You can copy the access_token value from the response and paste it into Swagger preceded by the word BEARER, as in step 6 of the Get Authorized in Swagger tutorial above.