We cannot obtain a refresh_token through the access_token generated by our Flutter app. When attempting to generate a refresh_token using this access_token, we receive the message ‘unauthorized.’
2 Likes
Hi @bcoder ,
Welcome to the Google Cloud Community!
There are many reasons why you might be receiving the “Unauthorized” error. It’s difficult to debug without seeing your entire code, particularly the parts where you generate and access the tokens. Here are some pointers:
- Check Client ID and Secret: You’ll want to double-check the client ID and the secret key you’re using for generating the refresh token. They should be the same ones you have for your Flutter app in Google Cloud. If they don’t match, that’s probably why things are going sideways with the authorization.
- Look at Your Scopes: Have a look at the scopes you’re asking for when you’re trying to get that refresh token. They need to be the same as the ones you used originally for the access token. If there’s even a small mix-up or something’s missing in those scopes, it can throw a wrench in the whole authorization process.
Here are some StackOverflow threads that might give you an idea on how to troubleshoot your issue:
- 401 unauthorized error in Flutter but works fine in Postman
- Post to /refresh api returning ‘Unauthorized’
- How do I resolve this 401 error when trying to access a refresh token route on my MERN app? Passport JWT Local
- [What’s wrong with my get route? I’m receiving a 401 status code when I try to run my get route](http://What’s%20wrong with my get route? I’m receiving a 401 status code when I try to run my get route)
- Dio interceptor for refreshing access token
- How to solve error 401 is not authorized in a Flutter app
I hope this helps. Thank you.
1 Like