Skip to main content
Feedback

Prerequisites for using OAuth 2.0 authenticated GraphQL I/O Doc

To successfully test the OAuth 2.0 authenticated GraphQL API on the Developer Portal > I/O Doc section, ensure you have completed the following setup on Cloud API Management (Control Center):

  1. Created an API definition with a resource endpoint configured as a GraphQL endpoint:

    You must create an API definition with a resource endpoint, and configure it as a GraphQL endpoint on Control Center.

  2. Enabled OAuth 2.0 for the GraphQL API Definition:

    You must configure the following OAuth 2.0 fields on the API Definition Security Settings page:

    • Enable OAuth 2.0: Enable this toggle switch.
    • Grant Types: Select Client Credentials.
    • API Management Token API: Enable this toggle switch. Enabling the built-in Token API allows Cloud API Management to issue tokens directly - no external authorization server required.
  3. Created a Token endpoint for the same GraphQL definition:

    You must create a separate endpoint for the same GraphQL API Definition. This is your token endpoint. Developers use it to exchange their client_id and client_secret for a Bearer token.

  4. Configured GraphQL endpoint Key & Method Detection:

    You must configure the following authentication fields for the GraphQL endpoint on the Key & Method Detection page:

    • Request Authentication Type: Select OAuth 2.0
    • Grant Type: Select Client Credentials

    Based on these authentication field settings on the Key & Method Detection page, the developer has to provide the Access Token value in the GraphQL editor's authentication field for testing a GraphQL API. Refer to the OAuth 2.0 Authenticated GraphQL I/O Doc Usage Reference for more information.

  5. Configured both endpoints Domains & Traffic Routing:

    You must configure the following fields on the Domains & Traffic Routing page for both the GraphQL endpoint and the Token endpoint:

    • Customize your Public Endpoint Address:

      • For GraphQL endpoint: In the first text box, enter your public domain address, and in the second text box, enter the endpoint path.
      • For Token endpoint: In the first text box, enter your public domain address, and in the second text box, enter the endpoint path.
    • Your Endpoint Address: In the first text box, enter your backend domain address, and in the second text box, enter the endpoint path for both the GraphQL endpoint and the Token endpoint.

  6. Configured both endpoints CORS settings:

    You must configure the following CORS fields for both endpoints (GraphQL endpoint and Token endpoint) to enable browser-based requests on the Endpoint Cross-Origin Resource Sharing page:

    • Enable CORS: Enable this toggle switch.
    • Allow CORS Requests from any domain: Enable this toggle switch.
    • Sub-domain matching allowed?: Enable this toggle switch.
    • List of headers allowed: Provide authorization, content-type
    • Are cookies allowed?: By default, this is disabled. Keep it disabled.
  7. Created a GraphQL I/O Doc and provided access to it:

    You must create a GraphQL Interactive Documentation item on the Control Center Interactive Documentation page and provided access to it on the API Definition Interactive Documentation Access Control page.

  8. Created Package, Plan, Application, and generated credentials:

  9. Obtained a Bearer Token:

    Exchange your application's API key (client ID) and shared secret for a token using the Client Credentials flow. The Bearer token is obtained by exchanging the API key and secret (from the Developer Portal) with the token endpoint. Refer to the OAuth 2.0 Authenticated GraphQL I/O Doc Usage Reference for more information on how to obtain a Bearer token.

Next Steps

Once setup is complete, test your GraphQL API on the Developer Portal using the Bearer token for your registered application. Refer to Leveraging your GraphQL API Interactive Documentation.

On this Page