Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 5. ActiveDocs & OAuth
By the end of this tutorial, you will have a set of ActiveDocs that allow your users to test and call your OAuth-enabled API from one place.
5.1. Prerequisites Copier lienLien copié sur presse-papiers!
- You need to have a Red Hat Single Sign-On instance set up, and OpenID Connect integration configured. See OpenID Connect integration documentation for information on how to set it up.
- Additionally, you need to be familiar with how to set up ActiveDocs – see Add ActiveDocs and Create an OAS specification.
5.2. Client credentials and resource owner flows Copier lienLien copié sur presse-papiers!
This first example is for an API using the OAuth 2.0 client credentials flow. This API accepts any path and returns information about the request (path, request parameters, headers, etc.). The Echo API is only accessible using a valid access token. Users of the API are only able to call it once they have exchanged their credentials (client_id
and client_secret
) for an access token.
In order for users to be able to call the API from ActiveDocs, they will need to request an access token. Since this is just a call to an OAuth authorization server, you can create an ActiveDocs spec for the OAuth token endpoint. This will allow you to call this endpoint from within ActiveDocs. In this case, for a client credentials flow, the Swagger JSON spec looks like this:
For a resource owner OAuth flow, you’ll probably also want to add parameters for a username and password, as well as any other parameters that you require in order to issue an access token. For this client credentials flow example, you’re just sending the client_id and client_secret – which can be populated from the 3scale values for signed-in users – as well as the grant_type.
Then in the ActiveDocs spec for our Echo API we need to add the access_token parameter instead of the client_id and the client_secret.
You can then include your ActiveDocs in the Developer Portal as usual. In this case, since you want to specify the order in which they display to have the OAuth endpoint first, it looks like this: