Learn how to implement Google OAuth authentication in a Flask app on Replit, including user login and Google Sheets API integration.
https://YOUR_DOMAIN/oauth2callback
, while sending some information pertinent to the user and the login session.main.py
. The comments in the code explains what the individual parts do:
echo https://$REPLIT_DEV_DOMAIN/oauth2callback
. The result will look something like: https://81309e9b-c4df-48e0-a2c2-0a8d3c0e3162-00-35ppsa0tcuv6v.infra-staging.replit.dev/oauth2callback
. Copy this text and enter it as one of the “Authorized redirect URIs” in the bottom of the formhttps://YOUR_APP_DOMAIN/oauth2callback
GOOGLE_OAUTH_SECRETS
, and paste of the contents of the downloaded file
as the secret value."https://www.googleapis.com/auth/spreadsheets.readonly"
to the list of scopes:
googleapiclient.discovery
library is to first create a Credentials
object using the access token, and then use the build
function to create a callable API object. For the sheets API it looks like:
/oauth2callback
URI for to the “Authorized redirect URIs”.