gpt4 book ai didi

javascript - Google Authentication JS API 重定向到错误的 URL

转载 作者:行者123 更新时间:2023-12-03 00:50:31 25 4
gpt4 key购买 nike

我已经使用下面的代码几年了,直到一个月前它都工作正常。

MY_CUSTOM_URL 已在 Google 授权的重定向 URI 上声明和注册。

        function initClient() {   
gapi.client.init({
apiKey: APKEY,
clientId: CLIENTID,
discoveryDocs: ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"],
scope: "https://www.googleapis.com/auth/calendar",
redirect_uri: MY_CUSTOM_URL,
ux_mode: 'redirect',
}).then(function () {
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());

});
}

当我尝试调用 gapi.auth2.getAuthInstance().signIn(); 时,它只是忽略 MY_CUSTOM_URL 并重定向到默认网站根域,甚至当我使用 localhost(也在 Google 上注册)时,并且未进行身份验证。

如果我评论ux_mode,它会打开一个弹出窗口并正常工作,但我无法将弹出窗口用于此目的。

谢谢

最佳答案

来自Doc

Required. Determines where the API server redirects the user after the user completes the authorization flow. The value must exactly match one of the redirect_uri values listed for your project in the API Console. Note that the http or https scheme, case, and trailing slash ('/') must all match.

检查API Console中的redirect_uri ,使其与您的 MY_CUSTOM_URL

匹配

在这里你可以找到它

选择 api => 凭证 => 选择 OAuth 2.0 客户端 ID => 授权重定向 URI [输入字段]

关于javascript - Google Authentication JS API 重定向到错误的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53064975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com