添加Google OAuth API范围后出现“Something went wrong”错误求助
Google OAuth 测试应用请求Slides API权限时出现"Something went wrong"错误
- 我的Google Cloud项目为外部测试类型(无法改为内部类型),处于测试状态下,请求
profile这类基础权限范围时OAuth登录流程完全正常;但请求Slides API的https://www.googleapis.com/auth/presentations权限范围时,在点击"Google hasn't verified the app"提示框的"continue"按钮后,会弹出"Something went wrong"错误。 - 已完成以下排查操作但问题仍未解决:启用Slides API、在OAuth consent screen中添加对应权限范围、清除该项目关联的所有应用权限。
复现代码
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'))
问题截图
内容的提问来源于stack exchange,提问作者Ch33zig
相关产品推荐
相关产品推荐

