0
我试图获得刷新令牌,一旦用户授权与谷歌。 因此,用户不必再次授权。 我研究了Google的文档,并且我知道我必须将访问类型设置为离线。谷歌API获取refrest token:未捕获ReferenceError:脱机未定义
var cid = 'XXXXX';
var apik = 'XXXX';
var scopes = 'https://www.google.com/m8/feeds';
function authorizeWithGoogle() {
gapi.client.setApiKey(apik);
gapi.auth.authorize({ client_id: cid, scope: scopes, immediate: false, accesstype: offline }, handleAuthResult);}
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
console.log(JSON.stringify(authResult));
$.get("https://www.google.com/m8/feeds/contacts/default/full?alt=json&access_token=" + authResult.access_token + "&max-results=11700&v=3.0",
handleGoogleContacts);
}
}
HTML代码:
现在,我有以下的javascript代码试图
<input type="submit" class="btn btn-info" value="Google" onclick="authorizeWithGoogle()"/>
<script src="https://apis.google.com/js/client.js"></script>
它给我以下错误:
Uncaught ReferenceError: offline is not defined
任何人可以帮助我吗?谢谢
谢谢你的回复。 现在,我得到了以下格式的结果,我没有得到刷新标记{“state”:“”,“access_token”:“”,“token_type”:“承载者”,“expires_in”:“3600”,“范围“:”https://www.google.com/m8/feeds https://www.googleapis.com/auth/contacts","client_id":"","response_type":"token","issued_at“: “1429740898”, “expires_at”: “1429744498”, “状态”:{ “google_logged_in”:假的, “signed_in”:真正的 “方法”: “提示”}} –