When I try to add a scope that has an API, I get “Google hasn’t verified the app”, which is expected because I have it set as testing, but when I click on “continue”, I get “Something went wrong”. However, if I request a scope like profile, I don’t get the “Google hasn’t verified the app” nor the “Something went wrong”, but I can continue with “Sign in to Project” with no issues. Here is a simple piece of code that doesn’t work for me:
const { OAuth2Client } = require('google-auth-library')
const express = require('express')
const dotenv = require('dotenv')
dotenv.config()
const REDIRECT_URI = 'http://localhost:3000/oauth2callback'
const oauth2Client = new OAuth2Client(process.env.CLIENT_ID, process.env.CLIENT_SECRET, REDIRECT_URI)
const getAuthUrl = () => oauth2Client.generateAuthUrl({
access_type: 'offline',
// scope: ['https://www.googleapis.com/auth/userinfo.profile'],
scope: ['https://www.googleapis.com/auth/presentations'],
})
const getToken = async (code) => {
const { tokens } = await oauth2Client.getToken(code)
oauth2Client.setCredentials(tokens)
return tokens
}
const app = express()
app.get('/', (req, res) => {
const authUrl = getAuthUrl()
res.send(`<a href="${authUrl}">Authorize</a>`)
})
app.get('/oauth2callback', async (req, res) => {
const { code } = req.query
try {
const tokens = await getToken(code)
res.send('Authentication successful! Tokens: ' + JSON.stringify(tokens))
} catch (error) {
res.status(400).send('Error during authentication')
}
})
app.listen(3000, () => console.log('Server running on http://localhost:3000'))
I’ve made sure that I’ve enabled the slides API, added the scope to the OAuth consent screen, and deleting connections with my project in my app permissions. The project is in testing and is External, because I can’t make it Internal.