gem - GooglePlus::RequestError: Invalid Credentials -
i`m getting 'googleplus::requesterror: invalid credentials' google plus rails gem.
can't understand since when use sign in user works fine, im using credentials retrieved display info user, then, if works temporarily, after day or 2 error:
'googleplus::requesterror: invalid credentials'
my helper code:
def google_friends(user) auth = user.social_auths.where(provider: 'google').first if auth begin googleplus.api_key = env['google_key'] client = googleplus::person.get(auth.uid, :access_token => auth.token) client.emails.first["value"] rescue '' end else '' end end
thanks in advance.
you have give access_type=offline while authorization. , need use refreshtoken refresh new access token operation.the access token have expiery time. if want use acess token have refresh it.otherwise invalid token after expiry.
Comments
Post a Comment