NoamB / sorcery

Magical authentication for Rails 3 & 4
MIT License
2.31k stars 386 forks source link

How do I set custom Oauth2 params & get/use a refresh_token #702

Open Jamedjo opened 9 years ago

Jamedjo commented 9 years ago

Once I've used oauth2 to log someone in, I'd like to reuse their token to access the google drive API. This works but the token times out after 1h.

I'd like to be able to add access_type=offline to the auth params. Is this possible? What is the best way to get/use a refresh token?

I also previously wanted to add hd=mydomain.com and other custom params listed at https://developers.google.com/identity/protocols/OpenIDConnect#authenticationuriparameters

arnvald commented 9 years ago

Hi @Jamedjo

I'm afraid it is not possible to set these params at the moment. They need to be added as attr_accessors to lib/sorcery/providers/google.rb and used in the authorize_url method (IIRC, I haven't used this code for a long time). I'll be happy to merge PR that adds this.

Refresh token should be available in sorcery_fetch_user_hash method that is available in external submodule