Я пытаюсь получить токен обновления после авторизации пользователя с помощью google. Так что пользователю не нужно снова авторизоваться. Я изучил документацию от Google, и я узнал, что мне нужно установить тип доступа в автономном режиме.Google API получает токен refrest: Uncaught ReferenceError: offline не определен
Теперь я пытаюсь со следующим кодом JavaScript:
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>
Это дает мне следующее сообщение об ошибке:
Uncaught ReferenceError: offline is not defined
Может кто-нибудь мне помочь? спасибо
Благодарим за сообщение. Теперь я получаю результат в следующем формате: я не получаю обновленный токен {"state": "", "access_token": "", "token_type": "Bearer", "expires_in": "3600", "scope ":" 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": правда, "метод": "ПРИГЛАШЕНИЕ"}} –