How to authenticate a ip server in firebase authentication? - javascript

I tried using auth in firebase for google sign in. I have done it countless times before only though the preview web server was localhost:3000 and so I would get a error saying
This domain localhost:3000 is not authorized to run this operation. go to -> Auth section -> Sign in method tab.
So i would follow the instructions and enter my authorized preview url as localhost and it would be fine. but this time i'm not using localhost, but i'm using some kind of ip address server and when i try to enter it in firebase it would say "app has to end like a for eg: .com" but my ip server doesn't have a .com or something so firebase doesn't allow it
Also there is nothing wrong with the code i have used it many times before in a localhost 3000 server and it works because firebase auth allows localhost but not ip servers. what should i do?

Authorization is for an entire domain, not for a specific port on that domain. So 127.0.0.1 is a valid authorized domain (and is added by default when you create the project), but 127.0.0.1:5500 is not.

Related

How do I send my stripe webhook to my Heroku app?

I've integrated Stripe into my javascript app which works fine in my test environment using ngrok but once I switch to prod, my app is timing out as users attempt to leave the Stripe checkout screen.
The Stripe webhook kicks error Timed out connecting to remote host and I think it's because I have the wrong endpoint.
Testing endpoint
https://6752-136-62-45-90.ngrok.io/users/stripe/webhook
Live endpoint
https://myapp.com/users/stripe/webhook
Everything else in the integration appears to work -- the customer is still created and the billing goes through but I need the endpoint code to run because it builds some critical infrastructure in the user profile.
I also have SSL encryption setup and DNS target on my Heroku application so I'm wondering if I should be using the DNS target or the Heroku app name for the endpoint instead of my domain.
My question
I can't really find any documentation on this but how do I configure my Stripe endpoint with my Heroku-hosted app?
You can test by setting the Heroku app name directly to check if it works to narrow down the issue. If it still doesn't, then most likely it's due to network issue.
Timed out connecting to remote host usually means that the server is not responding. This is likely due to network configuration such as firewall blocking the Stripe IP addresses. I'd recommend checking your network configuration and ensure that Stripe domains/IP addresses are in the allowed list: https://stripe.com/docs/ips

client IP is different each page reload in heroku

I'm trying to get the client IP as a way to save a particular user so the server knows who they are next time they visit, without having the need to login/signup for anything. This is a React front end with a NodeJS backend.
I tried my app locally and it seems to work fine. But I tried deploying it to Heroku and now I'm getting different IP addresses each time I reload. It keeps the same IP for the duration of the visit, but once I reload (refresh) the page, my IP changes..
[Method: 'POST'] [Path: '/api/posts'] [IP '::ffff:***.63.***.219']
[Method: 'POST'] [Path: '/api/posts'] [IP '::ffff:***.47.***.144']
(actual ip modified)
this is my console, as you can see the IP is completely different, and it looks nothing like my IP. I'm getting the IP from the request object (request.ip).
Why is the IP different each time on Heroku but stable on my local machine? is there another method for getting the client IP that I should be using? or is this a Heroku problem? I've looked for answers about this but I have come up empty which makes me think this is specific to Heroku.
According to the Heroku Documentation, all requests are going through a Proxy which acts mainly as a load balancer (If I have it correct in mind). You can use the custom HTTP-Headers to get the client ip address, but it is not recommended!
Additional:
For security reasons you should avoid to use the IP to identify a user, because that can cause session hijacking. Use technologies like cookies instead!

Google signin: Permission denied to generate login hint for target domain (javascript web app)

I'm using the Google signin Javascript API (that is, the gapi-signin-button) on a webapp. The app is served by a gulp server, binding to 0.0.0.0. The login process works when I develop locally, but when I run on a remote server and access the page via the public IP, I get the following signin error:
Error: invalid_request
Permission denied to generate login hint for target domain.
I have both localhost:PORT and SERVER_IP:PORT in my Authorized JavaScript origins. Other SO answers have said I should be binding to localhost instead of other interfaces, but that doesn't apply here since if I bind to localhost the server can't be accessed remotely. What do?
I had this same problem and just figured it out. You can't use numerical ip addresses (like http://0.0.0.0) as redirect uris in Google. It has to be an actual url, like http://mycompany.com.

I would like to test the stocktwits API on localhost. Is this possible?

Right now I am integrating a meteor.js app with the stocktwits API. Since I have not decided on a domain name yet and may be far off from this process, is there anyway test the stocktwits api locally (localhost, port 3000) ? Ideally I would like localhost:3000 for my "Website URL" and "Site Domain." However when I try to set these under the ST API create an app dashboard, I am getting errors about invalid website url and site domain. Any workarounds here ??
Also I would like my redirect_uri to be http://localhost:3000/_oauth/stocktwits
When I try to authorize the user the stocktwits popup window does appear - however I get the following error: Error: invalid_request redirect_uri must be absolute with http or https scheme I am assuming that is because my redirect_uri is not a live domain name.
I have tried this myself, but was unable to do it. The call has to travel from the server to StockTwits, then back but http://localhost is not available outside of your network.
I setup a testing domain on a live web server to test and it worked just fine. Good luck!

openid and facebook authentication in webapp running on localhost

My java/javascript web application is in development, and I hava a javascript application that communicates with my database (where I maintain my own userids) using ajax POST commands to a servlet container running on localhost, within a vmware machine. I want to be able to login using Google, Yahoo, and Facebook authentication, on this development setup, but in studying Facebook's OAuth 2.0 method, it looks like your web application has to hava a link to the facebook site, and provide a redirect link back to your own site when authentication is finished. This method won't work because facebook can't redirect to a localhost address and reach my machine, which doesn't have a web presence.
Do I have the same issues with OpenID and Google/Yahoo authentication?
Andy
Facebook OAuth works with localhost apps. This is because Facebook redirects the browser to the redirect_uri you supply in oauth, your browser knows where http://localhost is (I actually used a virtual host in apache & windows vhosts, don't know if you can enter localhost as website url in your app settings). Works perfectly
Google Oauth however, in my experience, doesn't work on local version. Somehow the site needed to be accessible from Google itself (not just the browser) for this to work, and it didn't, so it doesn't (I don't remember the exact details, sorry)
Don't know about the others
You could add DNS entries on your local machine so that mysite.com resolves to your local computer.
By doing this, you will be able to login from your local machine to do your tests.
In Windows, you can do this by editing the file:
C:\Windows\System32\drivers\etc\hosts
Add a new line:
127.0.0.1 mysite.com
Regarding OpenID, I am not sure if would accept logins from localhost URLs, but it will surely work after adding the entry in the hosts file and having a proper domain (even though it RESOLVES only on your computer).
The trick is that after login, Facebook or Google responds to your application with something like this: redirect the user to mysite.com as authenticated. Your browser then will resolve mysite.com as your machine and it is all working.

Categories

Resources