How can I solve this Access was denied (www-authenticate header was: Bearer realm="https://accounts.google.com/", error=invalid_token)
Asked Answered
B

0

7

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));
}

}

Busboy answered 3/7, 2020 at 14:52 Comment(1)
Did you get a solution to your problem?Redfish

© 2022 - 2024 — McMap. All rights reserved.