Google API Key Generation
{info} This doc was added since google is a common choice for authentication but is not the easiest to figure out.
To set up the google API (which we use for authentication), just follow these steps.
- Go to the Google API Console.
- Click on the drop down to the right of “
Google APIs
”.
- Click the “
New Project
” button on the top right of the modal.
- Give the project a name you will easily recognize. I used
[PROJECT] - Local
.
- By this example I mean that I set the name to
<My Project>
and then the environment the key will be for.
- Wait a bit for google to finish generating your project.
- You will know it is done by clicking on the drop down again. If it is not there, it’s still being created.
- Once it is done click on it.
- Click “
Credentials
” on the left hand side.
- Click on “
OAuth consent screen
”.
- Fill out these details.
- Product name: “[PROJECT] - Local”
- Everything else is either pre-filled or can be left empty.
- Click “
Save
”.
- The page should redirect to “
Create OAuth client ID
”.
- If it doesn’t, use these steps to get there.
- Go to “
Credentials
”.
- Click “
Create credentials
”.
- Select “
OAuth client ID
”.
- Fill out the form.
- Web application
- Name: anything
- Authorized JavaScript origins: empty
- Authorized redirect URIs: [your local site]/callback/google
- For example, mine was: http://[PROJECT].dev/callback/google
- Add the client ID and client secret you are given to your
.env
.
GOOGLE_KEY=
is where you put your client ID.
GOOGLE_SECRET=
is where you put your client secret.
GOOGLE_REDIRECT_URI=
should be the same as the Authorized redirect URI
you gave the previous page.
- Back in google console, click “
Library
” on the left.
- Type “
Google+
” into the search and select “Google+ API
”.
- Click “
ENABLE
”
- That’s it!
For easy copying into your .env
GOOGLE_KEY=
GOOGLE_SECRET=
GOOGLE_REDIRECT_URI=