我正在尝试实现Google集成来登录和退出应用程序。我使用的是react库react-google-login。
<GoogleLogin>工作很好。但当我试图退出的时候,它只是把州设了出来。从下面的代码可以理解
<GoogleLogout
buttonText="Logout"
onLogoutSuccess={(response) => { this.setState(() => { return { isSignedIn: false } }) }}
></GoogleLogout>相反,我想将用户从google本身完全注销。
发布于 2020-08-09 06:54:26
从您的代码和react文档-google-登录,您可能错过了一些必要的道具?您应该为<GoogleLogout>提供三个必需的支持:clientId、onLogoutSuccess和onFailure。有一个来源:https://github.com/anthonyjgrove/react-google-login#logout-props
发布于 2021-01-21 12:20:33
我也有同样的问题,所以我安装了gapi脚本并添加了一个按钮:
<button type="button" class="btn btn-danger btn-sm" onClick={this.logout}>
Logout
</button>点击我就可以这样做:
logout (response) {
this.setState(state => ({
isLogined: false,
accessToken: ''
}));
const auth2 = gapi.auth2.getAuthInstance();
if (auth2 != null) {
auth2.signOut().then(
auth2.disconnect().then(console.log('LOGOUT SUCCESSFUL'))
)
}
}https://stackoverflow.com/questions/63323011
复制相似问题