OAuth 2.0: Configuring a new API proxy
If you are using the Apigee Cloud version of Edge, then you will see that a proxy called oauth is included in your organization by default. This proxy provides two sample endpoints for generating access and refresh tokens. If you'd like to learn more about OAuth token endpoints, see Understanding OAuth endpoints.
This proxy is not provisioned by default in Apigee Private Cloud installations of Edge. If you are on a Private Cloud, or if you do not see the oauth proxy in your org for any reason, a copy of it is maintained in the api-platform-samples repo in GitHub. The README has instructions for deploying the proxy.
The client credentials grant type defines a procedure for issuing access tokens in exchange for app credentials. These app credentials are the consumer key and secret pair that Apigee Edge issues for each app that is registered in an organization. For more details, see Implementing the authorization code grant type.
Add OAuth 2.0 to a new API proxy
You can easily add OAuth verification to an API when you create a new API proxy.
- Log in to your Apigee Edge account.
- Select APIs > API Proxies.
- Click + API Proxy.
- Use the wizard to create a Reverse proxy. If you're not familiar with this dialog, see Build a simple API proxy.
- In the Security section of the wizard, select the radio button next to OAuth v2.0.
When you select this option, two policies will be attached to the newly created API proxy, one to verify access tokens and another to strip the access token after it has been verified.
Note that the Publish API Product checkbox becomes selectable and is automatically selected. Check this if you want to automatically generate a product when you build the new API proxy. The autogenerated product will be created with an association to the new API proxy. If you have an existing product with which you want to associate this new API, be sure to clear this checkbox so that you don't create an unnecessary product. For information about products, see What is an API product?
Working with the default OAuth proxy
The oauth proxy exposes the following endpoint URI:
Publish this URI to developers who need to obtain access tokens. App developers configure their apps to call this endpoint, presenting their consumer key and secret pairs to obtain access tokens.
The default client credentials token endpoint is exposed over the network at the following URL:
For example, if your organization name is "apimakers", the URL would be:
This is the URL that developers call to obtain access tokens.
By default, out-of-the-box OAuth endpoints are only deployed in the test environment. Before they are available in prod, you must explicitly deploy the API proxy called
Call the API
When you get back an access token, you can call the API with an Authorization header and Bearer token, like this:
curl -H "Authorization: Bearer <your access token>" http://myorg-myenv.apigee.net/myapi
See also Verifying access tokens.
Help or comments?
- If something's not working: Ask the Apigee Community or see Apigee Support.
- If something's wrong with the docs: Send Docs Feedback
(Incorrect? Unclear? Broken link? Typo?)