I am trying to use a refresh token to request a new access token
My Code:
def google_client
return nil if self.refresh_token.blank?
Google::Apis::ClientOptions.default.application_name = "Qontak Development"
Google::Apis::ClientOptions.default.application_version = "1.0"
Google::Apis::RequestOptions.default.retries = 3
client = Signet::OAuth2::Client.new(
token_credential_uri: 'https://www.googleapis.com/oauth2/v3/token',
client_id: ENV["GOOGLE_CLIENT_ID"],
client_secret: ENV["GOOGLE_CLIENT_SECRET"],
refresh_token: self.refresh_token,
grant_type: 'refresh_token'
)
client end
But i get error like this:
{"error": "invalid_grant", "error_description": "Bad Request"}
I was wondering why it happened to some users? and the rest are okay? I have tried several solution including running this command sudo ntpdate ntp.ubuntu.com
like suggested by someone in https://github.com/google/google-api-ruby-client/issues/84, but still gives me the same errors, any help would be appreciated, thank you
{"error": "invalid_grant", "error_description": "Bad Request"}
Normally means that the client id and secrete you are using to refresh the access token. Was not the one that was use to create the refresh token you are using. Any chance you have created a new Client id and some of the users are using the old one?
Try and authenticate again get a new refresh token.