Create a project
- Start by accessing the Google developers console here (https://console.cloud.google.com/apis/dashboard) and create a new project if you don't already have one.
Now, within that project, you will need to enable APIs and services.
This will take your to their API Library. Simply search for "Calendar" and choose the Google Calendar API.
Now Enable the Google Gmail API
Whilst we've enable the Google Calendar API, we now need to obtain a client ID and a client secret to add to our application.
The important thing here is to ask for user data since we will be asking our user to connect to their Google Account through OAuth authentication.
Now we need to give the name of our application but most importantly, we need to whitelist the redirect URI that we want the user to be redirected to after the OAuth process. You can run valet share to get a random ngrok URL. (This will have to be updated whenever you rerun the valet share / ngrok, if you are on the free plan). If you are using the Google API on a live server, use its real domain instead.
Now that we have our domain, we just need to decide the route that we will use for our OAuth callback. We will be using /oauth/google. Therefore the full URL is https://${NGROK_URL}.ngrok.io/oauth/google
Click on you app name.
Here are your GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables. As you can see we've also successfully whitelisted our GOOGLE_REDIRECT_URI environment variables which, in our case, is https://602b-62-4-44-207.ngrok.io/oauth/google. You can always come back to this page later to update the redirect URI in case your domain name changes.
Add a test user (this will be the email of the agent you will use to test with - you can add up to 100 test users) and proceed to summary, where you should be done.
Your OAuth consent screen has been configured and your app has a publishing status of “Testing”. This means it can be used by a limited set of test users, which you can set up on the OAuth consent screen page. If you want to make your app generally available to all users, you will need to set the publishing status to “In production”. You will also need to submit your app for verification (https://support.google.com/cloud/answer/9110914), which can take up to 4-6 weeks (depending on which OAuth scopes your app uses).
Env variable APP_URL
needs to be changed to either a dev link (the ngrok tunel), or production url of the site, if app is in production.
While publishing status is set to "Testing", only test users are able to access the app. Allowed user cap prior to app verification is 100, and is counted over the entire lifetime of the app.