如何解决一键登录是否可以获取授权码?
我试图在有人单击后获得授权码,我正在获取客户端ID和凭据。但是我想获取授权码,以便我基本上可以获取访问令牌,但我正在获取访问令牌,但是我没有获取刷新令牌。那么我如何获得刷新令牌可以有人提出任何解决方案,这是我的代码
<html lang="en">
<head>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<script src="https://apis.google.com/js/client.js?onload=authorize"></script>
</head>
<body>
<h2>Infinity</h2>
<div
id="g_id_onload"
data-client_id="xxx"
data-callback="handleCredentialResponse"
></div>
<script>
function handleCredentialResponse(response) {
const config = {
scope: "https://www.googleapis.com/auth/plus.business.manage",client_id: "xxx",immediate: true,response_type: "permission",};
console.log(response,"here i am getting the credentials and client_id");
gapi.auth2.authorize(config,function (response) {
console.log(response,'here i am getting the access token ');
// i wanted the refresh token
});
}
</script>
</body>
</html>
解决方法
要获取可以交换为刷新令牌的代码,必须显示OAuth同意页面并获得最终用户的批准(即使之前已为您的客户批准了所有请求的范围)。 根本原因是,刷新令牌代表长期许可授予。用户必须知道并批准。
总而言之,不可能无声地获取代码(用于新的刷新令牌)。是否使用Google One Tap都没关系。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。