Skip to content

Latest commit

 

History

History
executable file
·
60 lines (42 loc) · 5.22 KB

AccessToken.md

File metadata and controls

executable file
·
60 lines (42 loc) · 5.22 KB

How to get Access Token to use in Species List Web Services:

Getting an Access Token involves mainly two steps. First, users need to acquire a client ID and client secret for his/her gmail account. Second, generate the access token using the client ID and the client secret. The two steps are described in detail below.

Get a client ID and client secret:

  1. Open the Google API Console Credentials page.
  2. Login using your gmail account.
  3. To view Credentials page, select an existing project or create a new one. Select a project
  4. If you have selected a project, then go to next step. Otherwise, create a new project by giving a project name and clicking Create. New project
  5. If you have already created credentials for an existing project that you selected in the previous step, then click on the name of the project. This will take you to a page where you can get the client ID and client secret. Move on to Generate tokens section. If you have created a new project then go to next step.
  6. On the Credentials page, select Create credentials, then select OAuth client ID. Create credentials
  7. Creating credentials for the first time for a new project might ask you to set a product name on the consent screen. Click on Configure consent screen. Type a name in Product name shown to users field and click Save. Configure consent screen
  8. Go back to the Credentials page and under Application type, choose Web application. Choose Application type
  9. Under Authorized redirect URIs, add a line with: https://developers.google.com/oauthplayground. Leave other fields in this page empty. Then click Create.
  10. On the page that appears next, take note of the client ID and client secret. You'll need these in the next section.

Generate tokens:

  1. Go to the OAuth2 Playground.

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

OAuth 2.0 configuration

  1. Make sure that:
  • OAuth flow is set to Server-side.
  • Access type is set to Offline (this ensures you get a refresh token and an access token, instead of just an access token).
  1. Enter the OAuth2 client ID and OAuth2 client secret you obtained above.

  2. 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/userinfo.email

Note that you need to use the above URL instead of using https://www.googleapis.com/auth/adwords that is shown in the picture below.

Authorize APIs

  1. If prompted, log in to your gmail account to grant access and authorization. Otherwise, confirm by clicking on Allow.

  2. In the section labeled Step 2 - Exchange authorization code for tokens, you should now see an Authorization code. Click Exchange authorization code for tokens.

Exchange authorization code for tokens

  1. A value will appear in the Access token field. This value is your desired access token for this gmail account.

Note that your Access Token will expire after certain time limit. In that case you can generate a new access token by clicking on the Refresh access token button.

Citation: The above procedure to get access tokens was created using google developers help guide.