Trying Out the API

In addition to viewing the SmartDocs API reference documentation, developers can use the
Try this API panel to interact with your API without leaving the API
documentation. In your portal, developers 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 working with your
API.

If your API requires an API key or authentication, you must configure your
portal so that your users can interact with your Cloud Endpoints API. This
page describes the requirements and configuration that you need to do so that
developers can use Try this 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

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 GKE),
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
Granting Access to the API
for information on how to assign these roles.

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.

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

Click Settingssettings.

On the Settings page, click the APIs tab and select your API
from the drop-down list.

In the APIs Explorer Settings section:

Copy the value of the apiKey field from the Firebase code snippet
and paste it into the Google API key field.

Copy the value of the authDomain field from the Firebase code
snippet and paste it into the Firebase auth domain field.

If you see an API with an API Audience in the form of
https://SERVICE_NAME, where SERVICE_NAME is the name of your Cloud
Endpoints service, then you have already created an API. Continue with
the next task to configure the Auth0 Application settings.

Otherwise, create an API:

Click + Create API.

Enter a name.

In the Identifier field, enter a URL in the format:
https://[SERVICE_NAME]

On the Auth0 Dashboard,
click the Applications menu option on the left navigation bar.

Select your Auth0 application or create a new one.

On the Settings tab of your application, 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.

Click Save Changes.

Keep your Auth0 Settings browser tab open 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.

Task 3: Configure Auth0 settings in your portal

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

Click Settingssettings.

On the Settings page, click the APIs tab and select your API
from the drop-down list.

In the APIs Explorer Settings section:

Copy the value of the Client ID field in the Auth0 Dashboard
and paste it into the Auth0 client ID field.

Copy the value of the Domain field in the Auth0 Dashboard
and paste it into the Auth0 domain field.