Cannot test Grails application which has oauth autontication inside LAN - grails

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

Related

Azure Application Gateway health check returns 301

I'm trying to configured an Azure Application Gateway in front of a web app. The web app is empty for now, only a single page to verify its running. I've added a custom domain and dns settings, verified in the network settings of the webapp. I've setup the AG following a few different links as I couldn't get a working example from a single source. I'm at the point now where my health checks are returning a 301. The lister is using port 80 as I have not setup the ssl yet. The app custom domain has no ssl binding either. The network security group has the default settings. I've checked the webapp before adding the private ip and it was fine, its just an empty page. So i'm wondering what could be causing the 301. Anyone have an idea what could be causing that or some further links I can check?
Thanks.
Resolved. The webApp had Https Only turned on in the settings, that was the cause of the 301. Doh!

How to use Google OAuth2.0 without out-of-band (OOB)

I have created new OAuth 2.0 Client IDs (application type = Desktop app). Then downloaded the OAuth client JSON file. Put the file into the folder where my code is looking. When I run the code locally on my PC it`s try to open following URL:
https://accounts.google.com/o/oauth2/auth?client_id={my_client_id}&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope={my_scope}&access_type=offline&response_type=code
and that is what I expect. Since the downloaded OAuth client has the parameter "redirect_uris":["http://localhost"]. So I expected the same thing when I ran this same code on the ubuntu server, but nope. The URL it proposes me visit is
https://accounts.google.com/o/oauth2/auth?client_id={my_client_id}&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope={my_scope}&access_type=offline&response_type=code
And here is the problem, I don't understand what I have to do to make my server pass this authorization.
I already tried to manually change this parameter of redirect_uris before visiting the destination to the same one I had on my local computer - to http%3A%2F%2Flocalhost%3A8080%2F, but I got this error in the browser:
Who can help me? What should I do?
Developers using installed applications need to stitch to using IP flow.
Loopback IP address (macOS, Linux, Windows desktop)
A key point on that page is
To receive the authorization code using this URL, your application must be listening on the local web server.
So as directed you would use http://127.0.0.1:port or http://[::1]:port The fact that you are getting a page not found is working as intended as you just have not set up the local web server as directed in the documetnation.
The authorization code needed for authorization can still be found in the URL browser. Currently this is the only information we have from Google and there is no other solution.

Possible to test Google social login locally?

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.

Blackberry Push notification : Java.io.IOException:Network operation(Subscribe)failed. Make sure that Content Provider Url is accessible

I am working on blackberry Push Notification and facing a big issue while registering from the device. I'm getting the Exception:
Java.io.IOException:Network operation(Subscribe)failed. Make sure that Content Provider Url is accessible..
I go through this guide and set up all things according to it.
However I am unable to register. My tomcat server is running and I can access content provider URL from my computer and the same from device's browser.
PC URL is: https:/loaclhost:8443/sample-push-initiator
I changed local host to IP address of my Computer. and can access it over WiFi.
Please help me regarding this.
Your push initiator URL must be publicly accessible from the internet to be accessible from your device. Using localhost or any local IP address (e.g. 192.168.0.2) won't work.
You'll have to set up your router to forward traffic on port 8443 to your PC's local IP.
You should ensure that this URL is accessible from your blackberry normal web browser (not the hotspot browser) before trying with the sample push app.

Facebook auth on mobile phone through router (Ruby on Rails - OmniAuth)

I am making an app for mobile phone, and I need to use Twitter and Facebook authentications.
My PC and my phone (Samsung Galaxy S2), on which I'm developing, are connected to one router.
My PC IP is 10.4.1.6. For Twitter authentication I just enter callback_url "http://10.4.1.6:3000" and everything works great, but for Facebook authentication I get:
"Invalid redirect_uri: Given URL is not allowed by the Application configuration."
I figured that if I can't enter the IP of my router then I can edit my hosts files on my phone and my PC to point to my Rails server, but still, no luck.
When I try to enter "http://rails_dev_work_pc.com:3000", Facebook is telling me that the URL is invalid. How can I fix this error?
EDIT:
I tried to enter this:
domain => "localhost.com"
callback_url => "http://localhost.com:3000/auth/facebook/callback"
in pc hosts => "127.0.1.1 localhost.com";
in phone hosts => "10.4.1.6 localhost.com
But I get the same error on my phone and my PC.
Also:
domain => "localhost"
callback_url => "http://localhost:3000/auth/facebook/callback"
in my pc hosts => "127.0.1.1 localhost";
in phone hosts => "10.4.1.6 localhost
works fine on the PC, but on my phone I get the invalid URL error.
I'm out of ideas..
I'm using this setup:
In hosts file, route localhost to localhost.com (or whatever you prefer). Now you should be able to use the following facebook app configuration:
App Domain(s): localhost.com
Website for facebook login: http://localhost.com:3000/
Canvas-URL (optional): http://localhost.com:3000/<yourfacebookendpoint>
Please let me know if this works for you as well. Also, I found it very helpful to have 2 facebook applications - one used for production (pointing to your production app URL) and one for testing only (pointing to your URL configured in the HOSTS file). That way, you can make tests without disrupting your production app.
EDIT
Here is the final solution that #ExEdzy posted as an edit to this answer:
I Just changed in hosts files this "localhost localhos.com" to "ip localhost.com"
In my phone the ip is ip of my pc (10.4.1.6). And in my pc hosts file the ip is "127.0.0.1"
And in facebook:
- App Domains: => "http://localhost.com:3000"
- Site URL: => "http://localhost.com:3000/auth/facebook/callback"
Worked like a charm.

Resources