KindeK
Kinde2y ago
1 reply
jasdeep

flutter SDK and getToken

hi,
I am using Flutter SDK and running into a situation where my accessToken and refreshToken have expired. As per docs I am using
Future<String> getNewToken() async {
  String? token = await sdk.getToken();

  if (token == null) {
    // Redirect user to the login page
    return 'Refresh Token Expired';
  }

  var box = await hiveEncryptedBox();
  await box.put('token', token);

  return token;
}

method to return 'Refresh token Expired' string so that I can initiate a new login process but what I am getting is that
sdk.getToken();
call is throwing 400 Bad Request error. The error response I get back is
{"error":"invalid_grant","error_description":"The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}

I face no issues in refreshing accessTokens as long as refreshToken is valid. Can someone point out to me what am I missing here?
Was this page helpful?