Refresh authorization using Google

  1. SDK Version: 35
    Android/iOS/

Hey all,

I am having trouble to understand how to use the Google API to request a new access token when the old one expired, using the refresh token.

I see on the docs https://docs.expo.io/versions/latest/sdk/google/ that the refresh token is returned after loginAsync(), but I don’t know what method to call and how to refresh my authentication…

I tried doing this HTTP call without success… is there a simpler better way to do this?

export async function getNewToken(refreshToken) {
  return await fetch('https://oauth2.googleapis.com/token', {
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      client_id: 'MY ID',
      client_secret: 'MY SECRET',
      refresh_token: refreshToken,
      grant_type: 'refresh_token',
    }),
  });
}

Thanks,

Matteo

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.