In early, my app is fine but few hour later I get this error. My follow is login to google drive and show that file in my app.
I/flutter (12843): Access was denied (www-authenticate header was: Bearer realm="https://accounts.google.com/", error=invalid_token).
here is my code.
Future<http.Client> getHttpClient() async {
//Get Credentials
var credentials = await storage.getCredential();
if (credentials == null) {
//Needs user authentication
var authClient = await clientViaUserConsent(
ClientId(_clientId, _clientSecret), _scopes, (url) {
//Open Url in Browser
launch(url);
});
//Save Credentials
await storage.saveCredentials(authClient.credentials.accessToken,
authClient.credentials.refreshToken);
return authClient;
} else {
//Already authenticated
return authenticatedClient(
http.Client(),
AccessCredentials(
AccessToken(credentials["type"], credentials["data"],
DateTime.tryParse(credentials["expiry"])),
credentials["refreshToken"],
_scopes));
}
}