OAuth Playground

Another option for generating OAuth2 credentials is to use the OAuth2 Playground. The OAuth2 Playground, in conjunction with the Google API Console, allows you to manually create OAuth2 tokens.

Prerequisites

Before creating credentials, you need to create a project , configure your user consent screen, and enable the AdMob API.

Get a client ID and client secret

Create a credential

  1. Open the Google API Console Credentials page .

  2. From the project drop-down, select an existing project or create a new one.

  3. On the Credentials page, select Create credentials, then select OAuth client ID.

  4. Under Application type, choose Web application.

  5. Under Authorized redirect URIs, add a line with: https://developers.google.com/oauthplayground

  6. Click Create.

  7. On the Client ID page, take note of the client IDand client secret. You'll need these in the next step.

You must configure an OAuth consent screen before using an OAuth 2.0 client ID.

  1. Open the Google API Console Consent Screen page .

  2. From the project drop-down, select the same project used to generate the credential.

  3. Configure your OAuth consent screen to use your OAuth 2.0 client ID. There are multiple ways to do this:

    1. Set your user type to Externaland publishing status to Published.
    2. Or, set your user type to Externaland publishing status to Testing, then add Test usersby selecting add usersto give them access to use your OAuth 2.0 client ID.

See additional information on setting up your OAuth consent screen .

Generate tokens

  1. Go to the OAuth2 Playground , (using this link should pre-populate some key values for you).

  2. Click the gear iconin the upper right corner and check the box labeled Use your own OAuth credentials(if it isn't already checked).

  3. Make sure that:

    • OAuth flowis set to Server-side.
    • Access typeis set to Offline(this ensures you get a refresh token and an access token, instead of just an access token).
  4. Enter the OAuth2 client IDand OAuth2 client secretyou obtained above.

    playground settings

  5. In the section labeled Step 1 - Select & authorize APIs, enter the following URL in the text box at the bottom, if it's not already there, then click Authorize APIs:

    https://www.googleapis.com/auth/admob.readonly

  6. If prompted, sign in to the account to which you want to grant access and authorization. Otherwise, confirm that the current Google user in the top right corner is the AdMob account for whom you want to obtain credentials.

  7. A prompt appears indicating your app would like to See your AdMob data. Click Acceptto continue.

  8. In the tab labeled Step 2 - Exchange authorization code for tokens, an Authorization codeshould appear. Click Exchange authorization code for tokens.

    playground authcode token

  9. If all goes well, the Refresh tokenand Access tokenshould be filled in for you (you may have to re-expand Step 2 - Exchange authorization code for tokens):

    playground refresh token

  10. Copy the Refresh tokeninto the configuration file for your client library of choice, along with the client IDand client secret.

  11. Configure a client library for OAuth in the AdMob API .

Remove the OAuth2 Playground from your client ID

Now that you have a refresh token, you no longer need the OAuth2 Playground to be an authorized redirect URI. To remove it from the list of authorized redirect URIs:

  1. Go to the Google API Console Credentials page .

  2. From the project drop-down, select your project.

  3. On the Credentials page, click the client ID nameto edit.

  4. Remove https://developers.google.com/oauthplayground from the Authorized redirect URIs. Note that you must leave at least one redirect URI in place.

  5. Click Save.

Revoke shared tokens

You can revoke shared tokens in two ways:

  1. Navigate to your Google account permissions page and revoke access from the relevant project.

  2. Alternatively, you can revoke web application tokens using the Google Identity API .

Design a Mobile Site
View Site in Mobile | Classic
Share by: