Generate API Keys
Learn to generate API keys required to call the Blogger APIs.
We'll cover the following
Now, we'll use the JSON file downloaded in the previous lesson to generate the API keys. We'll use our OAuth credentials from the JSON file to generate the authorization code that'll in turn enable us to generate the access token required to make API calls.
Generate authorization code
Step 1: Copy "client_id," "client_secret," and "project_id" from the downloaded JSON file.
Step 2: Click the "Edit" button in the widget below and enter the three keys in their respective textboxes. Then, click the "Run" button.
{ "installed": { "client_id": "{{CLIENT_ID}}", "project_id": "{{PROJECT_ID}}", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": "{{CLIENT_SECRET}}", "redirect_uris": [ "http://localhost" ] } }
Step 3: The above code will generate a URL and a prompt for an authorization code. Copy the URL given after "Authorize the app using:" and paste it in a new tab. You'll be redirected to the Google sign-in page.
Step 4: After you sign in to your Google account, you'll be asked to authorize the app. Click the "Allow" button. You'll now be given an authorization code.
Step 5: Copy the authorization code and paste it in the widget above where it asks for an input following the "Enter the authorization code:" prompt. Press the "Enter" key.
You'll get a JSON object as the output.
Generate access and refresh tokens
Step 1: Copy the JSON object from the output of the above code and paste it into the widget below.
Step 2: Click the "Run" button. The "access_token," "refresh_token," and "expiry" will be extracted from the output of the code below and saved as ACCESS_TOKEN
, REFRESH_TOKEN
, and EXPIRY
, respectively.
Step 3: Click the "Save" button to save these three API keys.
Note: The ACCESS_TOKEN expires after the EXPIRY time has elapsed. So, if a
401:Unauthorized
error occurs, head over to the appendix where we'll use the REFRESH_TOKEN to refresh the ACCESS_TOKEN.
Now that you've set up your API keys, you're ready to make your first call to the Blogger API!