</script>-6ren"> </script>-当通过浏览器在本地运行我的 Angular ( ionic 框架)应用程序时,一切正常,但是当通过 android studio 运行或打包并推送到手机中时,我得到 403。 这是在 index.ht-6ren">
gpt4 book ai didi

javascript - android 403 for <script src ="https://accounts.google.com/gsi/client"async defer></script>

转载 作者:行者123 更新时间:2023-12-05 00:29:43 27 4
gpt4 key购买 nike

当通过浏览器在本地运行我的 Angular ( ionic 框架)应用程序时,一切正常,但是当通过 android studio 运行或打包并推送到手机中时,我得到 403。
这是在 index.html 的这一行:<script src="https://accounts.google.com/gsi/client" async defer></script>我正在尝试根据此页面集成/实现“使用 Google 登录”按钮:https://developers.google.com/identity/gsi/web/guides/client-library
任何指针?
提前致谢!

最佳答案

我在 REACT 中遇到了同样的问题。
我的问题的解决方案是在 google.accounts.id 上方添加/* global google */。
/* global google */将此行放在我们的代码上方,它将自动引用 index.html 文件中的脚本。
React.js 示例

import './App.css';
import { React, useEffect } from 'react'
import jwt_decode from 'jwt-decode'

function App() {

function handleCallbackResponse(response) {
var userObject = jwt_decode(response.credential);
console.log(userObject);
}
useEffect(() => {

/* global google */ <-- Add this line before calling google.accounts.id

google.accounts.id.initialize({
client_id: "Your Client ID here",
callback: handleCallbackResponse
})

google.accounts.id.renderButton(
document.getElementById("signInDiv"),
{ theme: "outline", size: "large" }
);

return () => {
}
}, [])


return (
<div className="App">
<div id="signInDiv"></div>
</div>
);
}

export default App;

关于javascript - android 403 for &lt;script src ="https://accounts.google.com/gsi/client"async defer>&lt;/script&gt;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70954547/

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