0

I have an application that uses Google APIs in some places, and I want to avoid having the user login every time. Currently, I only receive a Google access token in the response, not a refresh token. How can I obtain the refresh token?

This is the function I use to when the user click to login with google:

    authenticate() {
      const client = google.accounts.oauth2.initTokenClient({
        client_id: 'MY_CLIENT_ID',
        scope: [
          "All_NECESSARY_SCOPES",
        ].join(" "),
        callback: (res) => {
          this.accessToken = res.access_token
          this.loadClient()
        }
      })
      client.requestAccessToken()
    },

It works for getting the access token. And I need the refresh token, Please Help Me :)

1 Answer 1

1

Client side JavaScript does not return a refresh token. It would be a security risk.

If you want a refresh token you need to use a server sided language like Node.js

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.