I'm getting a 401 Error even after I've called the refresh_access_token! method.
I'm getting a 401 Error even after I've called the refresh_access_token! method.
class MyClass
attr_accessor :client
def initialize(access_token, refresh_token)
@client = YouTubeIt::OAuth2Client.new(client_access_token:access_token,
client_refresh_token: refresh_token,
client_id: ENV['GOOGLE_CLIENT_ID'],
client_secret: ENV['GOOGLE_CLIENT_SECRET'],
dev_key: ENV['GOOGLE_DEV_KEY'])
# If YouTubeIt::AuthenticationError, refresh token
begin
@client.activity
rescue OAuth2::Error => error
if error.response.response.env.status == 401
@client.refresh_access_token!
end
end
end
end
My initial thought, was that this method would update the client with the new access token. However, since this didn't work I tried reinitializing the client with the new access token (OAuth2::AccessToken object) returned from the refresh_access_token! method like so:
I'm getting a 401 Error even after I've called the refresh_access_token! method.
I'm getting a 401 Error even after I've called the refresh_access_token! method.
My initial thought, was that this method would update the client with the new access token. However, since this didn't work I tried reinitializing the client with the new access token (OAuth2::AccessToken object) returned from the refresh_access_token! method like so:
Any clarification on how this method works would be much appreciated.