I want to test the Google Social login system on my local machine. However when I create a new OAuth button: 'Create New Client ID' it requires me to fill in the Authorized redirect URI which needs to be a valid address (ends with .com or .org).
Obviously when we develop locally we don't have the .com or .org at the end. I have a virtualhost setup... and my address to my local development is mywebsite.local
Is there a way to input the redirect URI to be mywebsite.local without receinv the error:
Invalid Redirect: http://mywebsite.local/login/auth must end with a
public top-level domain (such as .com or .org)
Further to pinoyyid's answer, here's what you'd want in your /etc/hosts file.
0.0.0.0 mywebsite.com
I put new rules after everything else that's already in there.
you can then access your development site at mywebsite.com and enter the correct redirect URL in the Google Developer's Console.
You can set "Authorized redirect URI" to local IP (like http://127.0.0.1/callback), it's working fine for me.
What really agonizing is that google don't allow user to config an external IP (let's say your server IP like 99.99.99.99) as "Authorized redirect URI", google want the "Authorized redirect URI" to end with a public top-level domain (such as .com or .org).
Just map your dev server IP address to dev.example.com in your /etc/hosts.
I made a simple tool for this exact purpose.
Just set your redirect URL to http://redirectmeto.com/http://mywebsite.local/login/auth
You can ngrok to tunnel your localhost into public site, as described here.
The key is to use an https URL on your local environment.
On OSX you can install local https certificate: https://github.com/FiloSottile/mkcert
Or use Laravel Valet.
So, your new localhost URL becomes: https://mywebsite.local
Then save this https callback on google. Works on my computer
In my experience you have to use localhost or url with public top level domain (I use .bar) and all redirect urls have to be https (in case you want to have verified google app - needed for sheets/drive api)
Steps will help for windows users:
Go to host file which should be C:\Windows\System32\drivers\etc
Create add entry in host file like
127.0.0.1 localhost.com
Save it. User localhost.com as a organization in google dev console.
Thanks.
Related
How do I test the Google OAuth 2.0 on my app with localhost, since Google requires a top private domain as the authorized domain?
I tried to look up solutions, but all the solutions given have been a while ago, and I think Google has changed their service since then.
localhost is not a valid top-level domain, and it won't let you generate credentials without setting up a consent screen. You can add more than one authorized domain if you'd like, but you can't leave it empty. But you CAN delete the field if you have no domains / would not like to add domains for now. you just can't LEAVE it empty.
Notice the description -- "When a domain is used". so it's not an obligation to add authorized domain for consent screen. Moreover, the authorized domain here is only related with consent screen. Authorized origins and Authorized redirect URLs needs to be specified in the credentials part, which is all that matters; specifying the origin from which requests will be accepted and where it will be redirected. So just omit the authorized domain in the consent screen.
So how to delete it? Just in case if you haven't noticed, just hover over the field and this little man will pop up. delete it. that's all. Now you should be able to save and continue, where it might ask you to setup scopes.
I know it's really late, hoping it might help others..
After about an hour banging my head against the wall I found this article that has a step by step solution that works (as of July 2020).
Basically you need to create a service account, share the sheet with that account, and then it should work.
All of the other auth methods I tried either raised nonsense errors, or simply silently didn't work.
The list of authorized domains is required before you submit a request for app verification. If you want to configure a localhost redirect URI, that is configurable in your web OAuth client ID configuration.
In case anyone has struck out on the suggestions above, this answer did the trick for me. Set my authorized JavaScript origins URI to http://localhost:8080 in the google API console then emptied my Chrome cache.
Just add an OAuth-consent-screen from here without a domain or valid domain that's up to you, after that create Credentials from here, then select OAuth client ID and enter your from here you can add javascript origin url and there you go you've done.
You add your final domain for when you are ready to become verified. Until then you will generate an OAuth client ID and enable https://localhost:3000 in "Authorized JavaScript origins"
Simple screenshot of the field you can enter localhost
Not beautiful, but works!
I've made local website(domain) on Xampp like test1.com, added that domain in Authorized domains and started Chrome from separate shortcut with parameter --ignore-certificate-errors
Note, that when you start with this flag, Chrome must not be running!
It cause Chrome to open web site in the xampp\htdocs folder and I was forced to go to folder test1.git and then to public folder, where finally site opened and the url was: https://test1.com/test1.git/public
ps. Use port 80 in httpd-vhosts.conf and not 443!
I have a problem when I access to my url.
If I enter myurl.com on browser, it redirects to my digital ocean server and shows the contents correctly. However, the url on the browser is changed to ip address:port/index right away.
I'm not sure what to change to show up with correct url (myurl.com) on the browser so that the users cannot see my ip address directly.
Below are the pictures of current setting.
Thank you in advance.
DNS Records on digital ocean side
DNS setting on google domain
I have a Grails project which I want to test in a Local network, but the problem is that I use OAuth for signing in and have specified localhost as my redirect URL to Google app which works fine on a single machine, but when other PC's try to use my app google returns the token to their PC because they are the it returning to localhost. I tried to specify My IP address to google redirect URL but it doesn't allow because it's not a public IP address. So does anyone have any suggestion on what I should do?
you need to have a domain name specifying the redirect url if your app goes out of your local environment(in your case to google.com).so the solution is test all aspects of ur app besides the login in ur lan enviroment
I am working on a Rails 4 app. On my laptop, development is done at localhost:3000. The actual domain of the site is roomidex.com.
How can I set up a Facebook app so it works on production and development?
Here is the current configuration:
App Domains: roomidex.com
Website With Facebook Login:
Site URL: http://www.roomidex.com
When I try to do a Facebook login on localhost:3000, I get this not surprising error:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException",
"code": 191
}
}
On the Facebook App page, click "edit App" then click "Advanced" in the left-hand navigation. Then for "Valid OAuth redirect URIs" add http://localhost:3000... or whatever you want the accepted redirect to be.
You can create a test app that's connected to your main app. On the Dashboard or Settings page for your main app. scroll down and you'll see "Test Apps" in the menu that runs down the left side of the page. The test app will inherit settings from the main app, but it will permanently be in development mode, and it will have its own ID.
More info on test apps here:
https://developers.facebook.com/docs/apps/test-apps/
The protocol for setting up an app to work on localhost has changed. After you get your test app set up, this explains the steps for setting it up to work on localhost:
https://stackoverflow.com/a/24253054/2803458
Your error is saying
localhost URL is not allowed in the application
I know, FB does not give a s**t about explaining, what do to in those moments, however, as far as I am concerned, I have found workaround.
Basically, you need to "whitelist" locahost url in your app
Here is what you are going to do
Go to the app edit/summary page
In the fourth field App Domains, you should already have roomidex.com, so add another address localhost
The urls mentioned above are only valid, if each one of them is put into tabs, where you set, how you app integrates with Facebook (website with facebook login, App on facebook, Mobile web, …)
I do this: I put my working URL, in your case roomidex.com into Website with facebook login, and my test, localhost URL, either into App on facebook or Page tab
June 2015
Go to My Apps > Settings > Basic
App Domains
localhost
Site Web
URL : http://localhost:8888/
Mobile URL : http://localhost:8888/
It didn't work with port 80 or without any port unfortunately.
Adding localhost to the Valid OAuth redirect URIs in the test app did not work for me but adding 127.0.0.1 did.
Facebook now requires "Valid OAuth redirect URIs" to be https.
To use https locally (localhost:3000), I used [ngrok][1] which allows you to use https by providing a tunnel. To do this:
I went to their website and downloaded their program
I extracted the file for the program
In my console, I went into the directory where ngrok was extracted to and entered 'grok http 3000' on my Windows machine, others may use './grok http 3000'
After entering that, ngrok provided a https address which I put into the Valid OAuth Redirect URIs field in Facebook
Then I started my server and was able to access it using that https address instead of localhost:3000
Just create two applications.
One for testing and one for release. You cannot supply the app with separate URL configurations.
Just edit your hosts file with your domain that pointing to localhost and it should work fine.
I have a site set up in IIS that I'm currently accessing via localhost, I'd like to access it via URL mysite instead for example... I have edited the binding in IIS to add mysite as a host, and have also added the line 127.0.0.1 mysite to the hosts file. When I try and access mysite via a browser it seems to be trying to go to the correct location but keeps requesting a username and password and won't accept the one I am logged on with (Windows Authentication is enabled in IIS).
Is there another setting somewhere that I need to change?
Thanks
Check the authentication in IIS for the site. It should be "Windows Authentication".
In addition, you can also check the IE settings for Local Intranet. It should be set to "Automatic logon with current user name and password" or "Automatic logon only in Intranet zone".