当在本地运行我的角度(离子框架)应用程序时,通过浏览器运行都很好,但是当通过android运行或打包并插入移动电话时,我会得到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
有什么指示吗?
提前感谢!
发布于 2022-08-09 07:56:45
我在反应中遇到了同样的问题。
解决我的问题的方法是在google.accounts.id之上添加google.accounts.id全球google */。
/*全局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;https://stackoverflow.com/questions/70954547
复制相似问题