Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Google Authorization Server state param? #80

Closed
smingins opened this issue Mar 20, 2014 · 5 comments
Closed

Support for Google Authorization Server state param? #80

smingins opened this issue Mar 20, 2014 · 5 comments

Comments

@smingins
Copy link
Contributor

Hi

Does your library support passing a state param for Google requests?

https://developers.google.com/accounts/docs/OAuth2WebServer#libraries

I need to pass through some data so I know where to redirect the user to and this seems to be the param to do so.

Just wondering if this is something I can do with this gem or not? And if so, how?

Thanks in advance!

Shane

@rubytastic
Copy link
Collaborator

Is using a rails session value not more easy and failure save?

@jakehockey10
Copy link

I don't know how obvious that solution is to most people, but could you outline your suggestion in a little more detail? I'm trying to redirect the user back to a specific page that won't always be the same. I need to be able to pass through an object's id. One problem with this though, is that I don't want to have to add a ton of valid redirect url's to my google developer console. Does this mean that dynamic redirect url's are not available?

@smingins
Copy link
Contributor Author

@jakehockey10 ... my pull requests were merged, #88 and #89, that should allow you to pass through that url or any piece of information that you would need to handle your redirect using the state param.

I am doing something like:

%a{href: "/invites/contacts/gmail?state=#{some_custom_users_url(@user, @Custom)}"}
Invite existing gmail contact list

So the value of state will be pass through and back to your callback url and then you do stuff and redirect to the url that you passed in the state param or if it's just the user_id you are passing you can use that to build your url.

Does that make sense?

@jakehockey10
Copy link

Yea that is kinda making sense. Thanks for the quick reply! So here is the link as I've constructed it through ruby on rails helpers:
<%= link_to 'Import Gmail Contacts', "/contacts/gmail?state=#{dropin_url(@dropin.id)}", id: 'import-gmail-link' %>
I'm looking at the request hash, it has 66 elements, one of which is the HTTP_REFERER. This is the only thing I can find that is giving me back the parameter I'm trying to pass through, but it is included in the whole url as such: http://localhost:3000/contacts/gmail?state=http://localhost:3000/dropins/10.

Is there someplace else more specific that I'm supposed to grab this state parameter from? The params object in the controller in the oauth2callback action does not consist of this state parameter.

Thanks again for your help thus far!

@jakehockey10
Copy link

I hope I didn't make you look into this too much here...I realized that I was still using 0.3.4. After getting 0.3.5, I was seeing the 'omnicontacts.user' element of the request ( I wasn't before ) and I started to see the query_string/query_hash elements of the request. Thanks for pointing me in the right direction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants