Using oauth 2.0 with subdomains

5,731 views
Skip to first unread message

Michel Girnyak

unread,
Dec 16, 2011, 9:16:19 AM12/16/11
to oauth...@googlegroups.com
Hello
In our application we use sub domains, that user can create their own uri for example user-domain.app-domain.com.
My question is can I set wildcard redirect_uri such as *.app-doamin.com?
I'm asced because in your docs you say that 
"redirect_uri        one of the redirect_uri values registered at the API console        Determines where the response is sent. The value of this parameter must exactly match one of the values registered in the API console (including the http or https schemes, case, and trailing '/')"

P.S. Thanks!

Breno de Medeiros

unread,
Dec 16, 2011, 1:23:40 PM12/16/11
to oauth...@googlegroups.com
Hi Michael,

What is the intended brand that the Google users are asked to approve?
Is it your application, or the sub-domains? If the latter, you
probably want to ask your subdomain owners to register with Google
separately. If the former, wouldn't it be possible for you to provide
a single OAuth2 handling endpoint? You can encode the user's starting
location in the 'state' parameter.

--
--Breno

Alexandr Gajdosh

unread,
Jan 13, 2013, 6:00:32 AM1/13/13
to oauth...@googlegroups.com
Hi
I faced same problem.
And here is my solution.
You register callback uri at googlele's api like "yourapp.com/auth/google_oauth2/callback"

In your application user from his subdomain "sub.yourapp.com" clickes button <%= link_to "Sign in with Google", "https://yourapp.com/auth/google_oauth2?state=#{his subdomain}" %>

In your routes file you define appropriate url. Now you have all you need + params[:state] with your subdomain

Vaibhav Singh

unread,
Mar 1, 2013, 1:42:57 AM3/1/13
to oauth...@googlegroups.com
Hi Alex,

I am facing the same issue.
What do you mean by the "routes". Is it an apache configuration that you are talking about.
Would be really great if you could elaborate routes.

Thanks
Regards

Vaibhav
Reply all
Reply to author
Forward
0 new messages