Trying Out the API

In addition to viewing documentation, you can configure your portal so that your users can interact with your Cloud Endpoints API. In your portal, users can send requests to your API and see the responses. Being able to try out your API in your portal will help your users understand what they need to do to get their own code to work with your API.

This page describes the requirements and configuration that you need to do so that your users can use your portal to try out your API. For each task, the minimum required Cloud Identity and Access Management permission or role required to complete the task is provided. For more information about Cloud IAM permissions, see the following:

Prerequisites

  • You must have deployed the API backend.
  • If your API requires an API key, your OpenAPI document must be configured as described in Restricting API Access with API Keys.
  • If your API requires authentication, your OpenAPI document must be configured as described in Authenticating Users.
  • Your API must be reachable through DNS.

    • If you deployed your API to the App Engine flexible environment, a DNS entry with a name in the format YOUR_PROJECT_ID.appspot.com is created automatically. This means that you can test your API in your portal without any additional configuration.
    • For other backends (such as Compute Engine or Kubernetes Engine), if your API is not configured to use a custom domain name (for example, myapi.mycompany.com), you must configure your API to use the cloud.goog domain.

Configuring API Explorer Settings

If your API requires an API key and/or Firebase or Auth0 authentication, you need to configure these settings before your users can try out your API. This section describes how to configure an API key and authentication settings.

Minimum required permissions: Users granted the Editor role on the API can configure the API Explorer settings. See Controlling API Access of Project Members for information on how to assign these roles.

API key

To configure an API key in your portal:

  1. In the GCP Console, go to APIs & Services > Credentials.

    Get an API key

  2. Be sure that the GCP project that the API is in is displayed in the drop-down menu at the top GCP Console window.

    • If you have an existing API key that you want to use:

      1. Click Edit API key edit next to the API key you want to use.
      2. To the right of the API key, click Copy content_copy to copy the API key to the clipboard.
      3. Click Cancel.
    • If you need to create an API key:

      1. Click Create credentials, then select API key.
      2. Copy the key to the clipboard.
      3. Click Close.
  3. Navigate back to your portal.

  4. Click Settings settings.
  5. On the Settings page, click the APIs tab and select your API from the drop-down list.
  6. In the APIs Explorer Settings section, paste the API key into the Google API key field.
  7. Click Save.

Firebase

To configure Firebase:

  1. Open the Firebase Console .

    • If you don't have an existing Firebase project:

      1. Click Add project and select the GCP project name that your API is in.
      2. Click Get Started on the Authentication card.
      3. Click the Sign-In Method tab.
      4. In the Sign-in providers section, enable the providers that you want to use.
      5. In the Authorized domains section, click Add Domain and add your portal domain name (for example, endpointsportal.example-project-12345.cloud.goog).
      6. Click Web Setup. The customized code snippet is displayed.
    • If you have an existing Firebase project:

      1. Go to Develop > Authentication.
      2. Click the Sign-In Method tab.
      3. In the Authorized domains section, click Add Domain and add your portal domain name (for example, endpointsportal.example-project-12345.cloud.goog).
      4. Click Web Setup. The customized code snippet is displayed.
  2. Leave the Firebase Console open because you will need to copy the values of the apiKey and authDomain fields from the code snippet and paste them into the API Explorer Settings fields on the Settings page in the portal for your API.

  3. Open another tab in your browser and navigate to your portal.
  4. Click Settings settings.
  5. On the Settings page, click the APIs tab and select your API from the drop-down list.
  6. In the APIs Explorer Settings section:

    1. Copy the value of the apiKey field from the Firebase code snippet and paste it into the Google API key field.
    2. Copy the value of the authDomain field from the Firebase code snippet and paste it into the Firebase auth domain field.
  7. Click Save.

See the Firebase documentation for more information.

Auth0

To configure Auth0:

  1. Log on to the Auth0 Dashboard.
  2. Click the Applications menu option on the left navigation bar.
  3. Select your Auth0 application.
  4. On the Settings tab, scroll down and add your Portal URL (for example, https://endpointsportal.example-project-12345.cloud.goog) to the following fields:

    • Allowed Callback URLs
    • Allowed Web Origins

    These fields accept multiple URLs separated by a comma. Be sure that the URL that you enter does not include a trailing / character.

  5. Click Save Changes.

  6. Leave the Settings tab displayed in the Auth0 Dashboard because you will need to copy the values in the Client ID and Domain fields and paste them into the API Explorer Settings fields on the Settings page in the portal for your API.

  7. Open another tab in your browser and navigate to your portal.

  8. Click Settings settings.
  9. On the Settings page, click the APIs tab and select your API from the drop-down list.
  10. In the APIs Explorer Settings section:

    1. Copy the value of the Client ID field in the Auth0 Dashboard and paste it into the Auth0 client ID field.
    2. Copy the value of the Domain field in the Auth0 Dashboard and paste it into the Auth0 domain field.
  11. Click Save.

See the Auth0 Dashboard Overview for more information.

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Endpoints with OpenAPI