【发布时间】:2021-12-18 19:11:51
【问题描述】:
如何 POST 到 Google 的 OAuth 2.0 端点以进行授权?
我正在 React 中构建一个 chrome 扩展,并且一直在关注 Google's documentation。这看起来很简单,但我并没有完全掌握实现的机制。
例如,在我的 popup.js 文件中,我调用了我的 background.js 文件,该文件执行和 axios POST 请求到创建的重定向 url。指南中的第 3 步说谷歌会提示用户同意,但是,这永远不会发生。我收到 200 条回复,但不知道该去哪里。
我做错了什么?谢谢!
axios
.post(
`https://accounts.google.com/o/oauth2/v2/auth?
scope=https%3A//www.googleapis.com/auth/drive.metadata.readonly&
include_granted_scopes=true&
response_type=token&
state=state_parameter_passthrough_value&
redirect_uri=https%3A//oauth2.example.com/code&
client_id=client_id` //actual values added
)
.then(function (response) {
console.log('RESPONSE', response);
});
【问题讨论】:
标签: javascript reactjs google-chrome-extension google-api google-drive-api