Google 授权返回 403 forbidden

时间:2021-04-16 14:54:04

标签: javascript google-api youtube-api youtube-data-api

使用 componentDidMount 方法反应组件,在 window.gapi.load 调用之后,在网络面板浏览器和控制台中,我有 403 禁止错误,响应如下。我看过文档,但没有发现 403 forbidden with this error message code。


    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="theme-color" content="#000000" />
        <meta
          name="description"
          content="Web site created using create-react-app"
        />
        <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
    
        <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    
        <script src="https://apis.google.com/js/api.js"></script>
        <script src="https://apis.google.com/js/platform.js"></script>
        <title>React App</title>
      </head>
      <body>
        <noscript>You need to enable JavaScript to run this app.</noscript>
        <div id="root"></div>
        
      </body>
    </html>

    componentDidMount() {
        const onInit = (auth2 => {
            this.setState(() => ({
                authorized: window.gapi.auth2.getAuthInstance().isSignedIn.get()
            }))
        }).bind(this)

        const onError = err => {
            console.log('error', err)
        }
        window.gapi.load('auth2', function () {
            window.gapi.auth2
                .init({
                    client_id:
                        process.env.REACT_APP_GOOGLE_CLIENT_ID,
                })
                .then(onInit, onError)
        })
    }

403 禁止

<块引用>

https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token id_token&login_hint = AJDLj6JUa8yxXrhHdWRHIV0S13cAQkWEAPWplFnV5UerxbKZb6kHhcraZKDnrovJi4PbVrzX39mlnv4ILIcpkZdqDkhhhY9wilNnFidqJ9v6El4y35zN64V74PuJxV-d6qoxXr-9TER1&CLIENT_ID = 20176736559-mu75ue3gimbftv2kvildmso7ravgpn5a.apps.googleusercontent.com&原点= HTTP://本地主机:3000&范围= openid 个人资料 email&ss_domain=http://localhost:3000

回复:

{
  "error" : "invalid_request"
}

有什么原因吗?我在开发者控制台上完成了所有步骤。

0 个答案:

没有答案