получить refresh_token от Google API - PullRequest
0 голосов
/ 21 января 2020

Я пытаюсь войти на веб-страницу с помощью библиотеки Google API JavaScript. Мне нужно получить токен refre sh, но мне не удается это сделать:

<html lang="en">
  <head>
    <!-- <meta name="google-signin-scope" content="profile email"> -->
    <script src="https://apis.google.com/js/platform.js" async defer></script>
  </head>
  <body onload="init()">
    <script>
      function init() {
        gapi.load('auth2', () => {
          const params = {
            client_id: '<SOMTHING>.apps.googleusercontent.com',
            scope: 'https://www.googleapis.com/auth/youtube.upload',
            prompt: 'consent'
          }
          gapi.auth2.init(params).then(onInit, onError);
        });
      }

      function onInit(data) {
        console.log(data);
      }

      function onError(err) {
        console.log(err);
      }

      var GoogleAuth;

      function startSignIn() {
        GoogleAuth = gapi.auth2.getAuthInstance();
        GoogleAuth.signIn().then(onInit, onError);
      }
    </script>
    <button onclick="startSignIn()">sign in</button>
  </body>
</html>

Как настроить объект gapi на возврат также refresh_token?

...