redirect uri error with oauth2 - php

I am a newbie in php, but I am a long time coder. I am trying to get the google drive api for php working with the example files provided, but I am getting a redirect error with the following information in the message:
redirect_uri=http://jppp.com:8080/interface/googletest/simplefileupload.php
In every answer I have seen the problem is that the redirect uri in the code does not mach that on the google console, but in my case they appear identical. Here is the line of code (from the example) I cant use localhost because the lamp server is hosted on docker, and google won't let you use an IP address for the uri. I ended up changing my hosts file for jppp.com to the docker container.
$redirect_uri = 'http://jppp.com:8080/interface/googletest/simplefileupload.php';
and here is the relevant section of my google console api credentials. I have also waited more than half an hour in case google was slow in updating and tried it in a different browser.
picture of google api credential screen
Can anyone see a difference between the code and the console? What else can I try to get this working?
Thanks,
Derek

Apart from having this URL added as an allowed redirect_uri, you need to configure the domain itself in the Google Console.
When you add it & verify ownership, then you can play with it. The section can be found here:
https://console.developers.google.com/apis/credentials/domainverification

Related

Strange facebook API error?

Local and preproduction versions of my website have same configs and same source code. For some reason preproduction version unable to communicate with Facebook API. When I'm trying to login using Facebook I'm getting such strange error:
Google translates the error message like this:
"You can not load the URL: field is not a URL is included in this application areas. To download this URL, please add all domains and sub-domains for your application to the "application domains" field in the application settings."
I have tried to add my domain to the list, but it didn't help.
The truth is, I'm stuck and I would be grateful for any hint what to do with the error.
P.S. Also I have no idea why the error message is in Arabic - Server from Germany and has en_US.utf8 locale.
Update Settings Basic (domain name changed)
Finally I found the issue. I've used cascade of reverse proxies (nginx), which modified $_SERVER['SERVER_PORT']. The modification leaded to inconsistency between generated redirect_uri and the value was specified in app settings in Facebook developer console.

Integrating youtube API in php on localhost

I'm developing a PHP app on my local computer and trying to use the public data API. The key has been generated and works well online, but as soon as I try to execute it on my localhost it returns
Access Not Configured. Please use Google Developers Console to activate the API for your project.
I have added these lines to the 'allowed referers' section in the developers console.
http://127.0.0.1
127.0.0.1
http://localhost/
localhost
http://myIpAddress
myIpAddress
None of them seem to help. This is the query sending via GET:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=######&fields=items%2Fsnippet&key=#######
My issue had nothing to do with the cases described here, but might help others.
I had a scenario where the API worked well online but not on localhost (WAMP), after migrating from old API.
The fix had to do with cURL, and I really can not explain why it did work online, I am not an expert, it's something related with SSL.
Basically, you need to turn of SSL verification, by using
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
According to your answer #neki-doar-fraer, i make the explanation more clear for other viewers of this post :
From the doc of YouTube API
Use a server key if your application runs on a server. Do not use this
key outside of your server code. For example, do not embed it in a web
page. To prevent quota theft, restrict your key so that requests are
only allowed from your servers' source IP addresses.
Use a browser key if your application runs on a client, such as a web
browser. To prevent your key from being used on unauthorized sites,
only allow referrals from domains you administer.
From the Google Developer Console, assuming you have already created a project, select the project you are working on.
Then from the side menu on the left select "APIs & Auth", then "APIs". From that screen you have to search for the YouTube API and then click the "On" button next to it.
I figured it out. I was using the browser key. Did not know there is a difference. Generated the server key and everything works.
I have always edited my HOSTS file to point the domain to LOCALHOST when testing things locally https://en.wikipedia.org/wiki/Hosts_(file)

I can't display my app on facebook

I'm having a little problem with the whole Facebook app development.
I created an facebook application and gave it an IP for my server.
I set my .php script file on the server and set the secret key and appId.
When I click on the app on my Facebook account to reach it, I get an "Uploading (0%)" text on the bottom of the browser and eventually I get a message:
"This webpage is not available".
When I used the "Heroku" hosting service, I got an app.
I think the problem is the communication between Facebook and my server but I don't know what.
I tried almost everything.
Can somebody help me?
If you issue a request to your application from the linter tool?
http://developers.facebook.com/tools/debug
If you run your own application url through there and don't see any activity then Facebook just cant access your server and you need to do some work with your firewall.

'An error occurred. Please try later' message on Facebook authentication dialog

I am a newbie who is trying to create a Facebook app using PHP and Facebook's PHP SDK. The app is hosted on Heroku, and the sample app that they provided is working fine. However, I am now trying to get the sample app to work on Apache 2.2, and I have encountered a lot of problems along the way. Well, straight to the point, my latest problem will be trying to do Facebook login on localhost, but the 'An error occurred. Please try later' appears on the popup dialog. This does not happen on Heroku.
Will someone please enlighten me on if there's any steps that I can take to overcome this error? I don't think it got to do with any coding error since I am just following the provided sample app. Thanks!
This is happening because FB does not recognize the URL of the host issuing requests. You need to determine what the FQDN of your localhost server is then add it to the Site URL section of the FB App Settings manager. Chances are you have the URL of your Heroku server in there now.
its simple. in local host you must create another sample application for localhost in facebook .and you must have the permission.then you can login and work with your local one.
simply for every copies of your app.you must create it in facebook
hope it help you
good luck

App on Facebook

I'm trying to run the example.php file that comes with the facebook sdk. I do have a hosting server that runs php, and also changed the ID's to the corresponding one on my app. Here is the message i'm getting:
This webpage is not available
The webpage at https://filipeximenes.com/facebook/ might be temporarily down or it may have moved permanently to a new web address.
Error 501 (net::ERR_INSECURE_RESPONSE): Unknown error.
i'm pointing the canvas to this adress: http://filipeximenes.com/facebook/
Thanks.
Based on your description, I think that this is your problem:
Do you have a valid security certificate on the hosting server? I ran into that problem recently when deploying an FB app. Since October, you have to have a valid cert even in sandbox mode for the FB app to run properly. If you don't have one it causes weird problems.
Just a thought that I hope helps.
One other thing to do from a debugging perspective is to take a look at the actual app running on your hosting server without viewing it via FB. If you get the same error message there, you know that it has nothing to do with the FB SDK.
Thanks!
Matt

Categories