In this tutorial, we'll be setting up Google authentication for Conduit.
Before we begin, we'll need to create a Google Application.
Configure Google
To begin the Google Authentication you need to get some credentials.
Go to your Google Console and create a new project.
Once you have a new project, you have to request your app credentials.
Click the CREATE CREDENTIALS
button at the top of the page.
Choose OAuth Client ID.
You will also be asked for an application type. Choose Web App
.
Your application credentials have been generated.
You will only need the client id and client secret.
You need to add an Authorized redirect URI.
Hit http://localhost:<CONDUIT_PORT>/hook/authentication/google.
A pop-up window will be displayed to you which contain your client id and client secret.
Authenticate with Google
To begin authenticating with Google you request a redirect url with the proper scopes
curl --location --request GET 'http://localhost:3000/authentication/init/google'
{
"result": "https://accounts.google.com/o/oauth2/v2/auth?client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fhook%2Fauthentication%2Fgoogle&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&access_type=offline&state=eyJpZCI6IjYzN
}
Open a browser and navigate to the url returned to you from Conduit.
Now the /hook/authentication
route has been triggered.
Once your browser has been redirected, your authentication has been completed.