I have an web application that uses google api (google drive). The application is used by many clients and every client has an subdomain to access the system.
So the domain is appdomain.com
And for users I have foo.appdomain.com, bar.appdomain.com, etc.appdomain.com.
But in google console redirect URI I have to manually put the redirect urls, is there any way I can use wildcards to redirect to make google accept any of subdomains like: *.appdomain.com ?
With this I can make the google authorization calls with the user subdomain in redirect_uri:
https://accounts.google.com/o/oauth2/auth?redirect_uri=http://foo.appdomain.com
Under Modify a Subdomain, locate the domain you want to redirect, then click its Manage Redirection link on the right. In the text box, type the URL you would like visitors to be redirected to if they go to the subdomain sample1.hgexample.com. Click Save. You will see the redirected URL under the Redirection column.
If you want to redirect your subdomain to your main domain, you can do this by editing your . htaccess file. Add the following lines of code to the file, replacing example.com with your actual domain name: RewriteEngine On RewriteCond %{HTTP_HOST} ^subdomain.example.com$ [NC] RewriteRule ^(.
Wildcard matching subdomains is not supported in Google OAuth. You could try using the state parameter and include the user-specific information there. This parameter will be returned to you in the response. More information on state here.
You can create a master subdomain to get all google auth responses and redirect to correct subdomain using the "state" query parameter.
For example create google.mydomain.com and use it as your valid "Redirect URI" and Apache will can redirect this url to each user with redirect (or rewrite) feature.
More info about apache redirects in http://www.simonecarletti.com/blog/2009/01/apache-query-string-redirects/
Here the code I'm using:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^google\.
RewriteCond %{QUERY_STRING} state=([a-z0-9]+)
RewriteRule ^(.*)$ http://%1.mydomain.com/$1 [L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With