javascript - Google API get refrest token: Uncaught ReferenceError: offline is not defined -
i trying refresh token once user authorize google. user don't have authorize again. studied documentation google, , come know have put access type offline.
now , trying following javascript code :
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 code :
<input type="submit" class="btn btn-info" value="google" onclick="authorizewithgoogle()"/> <script src="https://apis.google.com/js/client.js"></script>
it giving me following error :
uncaught referenceerror: offline not defined
can me?
accesstype: offline
<-- looking variable offline, not string. wrap in quotes.
accesstype: "offline"
next issue fact using submit button, not cancel form submission page going submit.
onclick="authorizewithgoogle(); return false"
there better ways cancel it, work fine inline events.
Comments
Post a Comment