Javascript Google API获取引用令牌:未捕获引用错误:未定义脱机
我试图获得刷新令牌一旦用户授权与谷歌。 这样用户就不必再次授权。 我学习了谷歌的文档,我知道我必须将访问类型离线 现在,我尝试使用以下javascript代码:Javascript Google API获取引用令牌:未捕获引用错误:未定义脱机,javascript,google-api,Javascript,Google Api,我试图获得刷新令牌一旦用户授权与谷歌。 这样用户就不必再次授权。 我学习了谷歌的文档,我知道我必须将访问类型离线 现在,我尝试使用以下javascript代码: var cid = 'XXXXX'; var apik = 'XXXX'; var scopes = 'https://www.google.com/m8/feeds'; function authorizeWithGoogle() { gapi.client.setApiKey(apik); gapi.au
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代码是:
<input type="submit" class="btn btn-info" value="Google" onclick="authorizeWithGoogle()"/>
<script src="https://apis.google.com/js/client.js"></script>
它给了我以下错误:
未捕获引用错误:未定义脱机
有人能帮我吗?谢谢你的回复。现在,我得到以下格式的结果,我没有得到刷新令牌{“state”:“access_token”:“token_type”:“Bearer”,“expires_in”:“3600”,“scope”:“:{“google_logged_in”:false,“signed_in”:true,“method”:“PROMPT”}
onclick="authorizeWithGoogle(); return false"