How to setup a local server which can accept oAuth callbacks? - php

I am not sure if this question has a place over here but I am having a lot of trouble setting up a local development server from where I can work on Facebook, Twitter, Google+ and other applications.
As of now I have an Apache environment and I am working on a PHP based platform. The database server is a standard MySQL server. Also, I am working behind a authentication based proxy.
The primary issue that I encounter is, when I made an application on Twitter and entered the relevant details like - website, callbackurl as 127.0.0.1. My application when tried to retrieve the oAuth key, it wasn't able to. I even tried out changing my listening post to something other than 80, but it didn't work either.
I understand that any application of this sort will encounter this problem because 127.0.0.1 is not an address that points to my computer precisely. And I am not aware of any other method other than this. Am I doing something wrong somewhere or is it impossible to develop/test applications which require oAuth via a locally deployed server.
Update
Port forwarding is not a solution because I am behind a firewall and I am part of a private network. Hence, my questions are-
Is this kind of development impossible in such a setup? If yes, then what can I do to? If I work using a dongle, will it possible? Or do I need to procure a static IP?

Related

How can I use my php webapp to interact with an API on localhost?

I've written a webapp in php, which works as a standalone app, but needs to get/post new data from time to time to an API (written by a different company, for desktop software) on localhost. When connecting, it would be from a webpage/browser open on that machine.
So far I've attempted to send curl requests, basically using the generated postman curl code, and it's returning false. I'm thinking it's because it can't connect to the localhost server, possibly because it's blocked from the internet.
I've been researching for a few days, but want a solution that doesn't involve me creating security vulnerabilities in the computers I am trying to connect to, by opening them directly to the internet, and if there is a way to send requests to localhost without installing more software on them I would be partial to that kind of setup.
Does this make sense? I hope someone has some experience or wisdom in this area that could at least nudge me in the right direction.
The localhost is always the computer where you refer to that host. You can't connect to the localhost from your webapp, because the localhost hostname for that app is the computer which runs it.
You have to open a tunnel from you computer to the internet where you webapp can communicate with it.
You can use ngrok to do that, for example

Choices regarding IP restrictions on web request

Didn't really know what title to give this question so I hope its acceptable.
I am using a system which has an API. I don't have a lot of control over this system, but one thing I need for security reasons is for it to be locked down to my IP. This works, so now the system can only be accessed from my IP.
Now, I have built a custom app which uses the above API. This app is hosted on a server which is different from my IP address. Therefore, when I try to make the API call it fails due to it being restricted. I know this is the case, because if I run the app locally from my location, it works without any problems.
So, the question is whats the best thing to do? I know I could add the IP address of the server which is hosting my app to the systems API. However, I think the servers IP is dynamic which could cause problems. I have also used things like no-ip locally to control my dynamic IP, but I cant imagine I can install this on my web server.
Looking for thoughts as to how I can overcome this problem.
Thanks

Is it possible to use the facebook API on XAMPP (local server)?

Is it possible to use the facebook api like we do it on sites live on the internet , but on XAMPP ( a local server) installed on my computer ? I'd really appreciate your feedback.
Mostly the API's should work fine unless you have a registered domain associated with the API app key.
You have not specified which API you are using [Facebook has a lot of API's with various security levels]
A few disadvantages on working on local machines are as follows
A local machine is identified as an anonymous request coming from some IP as its not associated with a domain. Therefore chances of blocking your API request are high.
Your system may have imposed firewall rules for incoming and outgoing requests, if your local server is not configured to send and receive outbound requests your might be in trouble.
Hope this helps.
This is sent from a mobile, don't ask me how but the comment system doesn't work nicely for me.
A local server is the same as a live website, the only difference is that you run it locally...
If you have an internet connection while running the server, you're basicly the same as every other server....
but well if you don't have internet on it don't expect it to be working....
[but ofcourse you can only connect to it locally and not from other computers xD]
I hope I answered your question now, Feel free to add a comment if you want to.
Yours sincerely,
Mike M.
Yes you can. Just make sure that redirect url must be the url which we put in the facebook while building the app.

Instagram redirect-uri fails for localhost

I am writing a PHP app to fetch all my photos with Instagram using their API. However, what puzzles me is, I run the app on my hosted server it works perfectly fine and the same app running locally does not work.
Here are some points on the app workflow:
The user sees the homepage and he will be prompted with 'sign-in with Instagram'
User signs in with Instagram and authorizes the app.
Instagram redirects the user.
The app then makes a request for access_token and receives it.
Using the access_token, the app will send further requests for user media
The response is parsed and the links to the images are now provided to the user.
All the above mentioned process works fine on my hosted server but fails at 'Step 3.' and redirects user to home page of my app.
The problem is localhost being the redirect_uri. Does anyone have a solution to this problem to use the app locally?
P.S: I have registered two separate clients on Instagram: one for locally hosted development and the other on a web server.
Also, I have tried localtunnel. Did not help either.
I know its a very very very old Question. but for those who get to this page hoping a solution:
instagram currently does not allow to use something like localhost or myvhost.test in redirection url, whats more it requires the url to be certified (https).
so the only working solution I could find is using ngrok. you should download it from the url, open it and type a localhost virtual domain name along with a specific port number like ngrok http myLocalUrl.test/app 80, hit enter and it will gives you two temporary public links.
it will remain valid until you close the ngrok command line. you can direct the link to a specific port number and direct the port number to specific folder path of the application in your localhost.
the tutorials provided by ngrok is simple enough if you did not understand my hints.
I was dealing with this issue trying to develop an Instagram App using NodeJS/Express.
I got around this by using my computer's external local IP rather than localhost, which you can grep for. I assume you're on a *nix machine, so do a very simple (and crude)
$ ifconfig | grep inet
which will return you a few ip and MAC addresses, one of them being your external IP. However this is lousy because it means every time you switch IPs you'll have to update your application's redirect_url with Instagram as well as update any code that relies on it.
Thankfully, there exists services like no-ip that will basically provide free DDNS service to you, so you need simply register a hostname with them and then drop that into your DEV env code as well as your development client's redirect url and you're set to go!

need to create an application that will work on the Internet also and local internet also

i need to make a website such that it can be accessed through the internet if internet is available otherwise when there is no internet then it should work properly on the local intranet also can this be achieved , i have built my site on php/mysql
if this can be achieved please tell me and direct me to some examples of how to achieve this
thankyou
Google Gears?
http://gears.google.com/support/
If you have a local web server, why not just host everything from there instead of hosting it elsewhere, and set it up so incoming connections from the outside hit that machine as well.
Or set up a remote sync that will keep all files on the remote server and the local server sync'd up. Could change DNS upon internet outage and have it resolve to the local server?
This will depend on how your network is configured, there are two likely scenarios that I can think of:
Your web server is behind a router and port 80 is forwarded
Your web server has it's own IP address on the internet
In the first instance you shouldn't have to do anything unless you want to access the website using a URL (e.g. www.mywebserver.com) in which case you'll have to play some DNS tricks on the local network to get it to point to the local IP of the server instead of the actual internet IP. For example when accessed from the internet the dns record for www.mywebserver.com would point to 12.34.56.78 where as the dns record for any machine on the local network would be something like 192.168.0.10.
In the second case to my knowledge there is nothing you can do that will allow you to be able to access on the intranet (I could be wrong so if someone posts a solution in this case I'll update my answer).
So the answer to your question really depends on your network configuration, If you expand on that a little giving a more concrete answer will be a little easier.

Categories