Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TokenResponseException #21

Closed
joshbrw opened this issue Nov 22, 2013 · 31 comments
Closed

TokenResponseException #21

joshbrw opened this issue Nov 22, 2013 · 31 comments

Comments

@joshbrw
Copy link

joshbrw commented Nov 22, 2013

When trying to get a access token using the requestAccessToken($code) method, I am getting this returned

{"error":{"type":"OAuth\\Common\\Http\\Exception\\TokenResponseException","message":"Failed to request resource.","file":"\/Users\/josh\/Sites\/richmedia\/vendor\/lusitanian\/oauth\/src\/OAuth\/Common\/Http\/Client\/StreamClient.php","line":62}}

Any ideas?

@ghost
Copy link

ghost commented Nov 24, 2013

artdarek : i have this error with facebook ,, can you help up ?!

@ikanc
Copy link

ikanc commented Nov 29, 2013

This will happen if you're trying to make a request with the same code twice.
Make sure that you are only using the request with the code once, get the access token, and use it for further calls.

Regards,
Ika

@joshbrw
Copy link
Author

joshbrw commented Nov 29, 2013

@ikanc I'm sending the authResult['code'] via ajax to this URL, then sending this code off using ->requestAccessToken(Input::get('code'));, this guide says to send the code to a page via Ajax, and I was assuming that you would use this code to request the access token.

@beer-lander
Copy link

same error with facebook

i try auth in local is normal.
but go online not.

seem lusitanian can't storage session /app/storage/sessions
'lusitanian_oauth_token|a:0:{}'

@belamagyar
Copy link

I had same error with facebook and google.

Check php.ini in the server and set
register_long_array: Off
register_globals: Off
allow_url_fopen: On

and use session_save_path(...) before session_start()
(e.g. on my host (ipage): http://www.ipage.com/knowledgebase/read_article.bml?kbid=600)

@vanderlin
Copy link

I think this is the reason the request needs to be ssl.

The URL used when authenticating a user is https://accounts.google.com/o/oauth2/auth. This endpoint is accessible over SSL, and HTTP connections are refused.
https://developers.google.com/accounts/docs/OAuth2WebServer

@VAggrippino
Copy link

I'm having the same problem trying to login with Facebook. I think that @artdarek might not have time to look at this issue right now, so I posted a question to Stack Overflow: http://stackoverflow.com/q/21720838/2948042

I'm currently working with localhost and the JavaScript API works, so I think my app configuration is correct.

Does anyone have this working? If so, please share what you did to make it work.

Thank you.

@MikeElghali
Copy link

hi,

@joshbrw in your php.ini activate this extention extension=php_openssl.dll

This resolved the problem.

@ghosh
Copy link

ghosh commented Apr 1, 2014

Getting the same error with Github.

Works absolutely fine on my local machine. Throws up the problem when is on the production server.

I tried the methods suggested by @jaoued and @yourri. No luck.

Anyone got any other suggestions?

@wnajar
Copy link

wnajar commented Apr 30, 2014

Having this issue as well with Facebook on a local server.

@ktaras
Copy link

ktaras commented May 6, 2014

Have the same problem with Vkontakte on my localhost. Could somebody help to solve it?

@ikanc
Copy link

ikanc commented May 6, 2014

Make sure you allow PHP SSL and your Firewall is not blocking.

Best Regards,
Ika Balzam, CTO | Net-Comet Development Studio | T: +65-9487-3791 |
ika@net-comet.com ika@net-comet.com | http://www.net-comet.com
http://www.net-comet.com

On Thu, May 1, 2014 at 7:26 AM, Will Najar notifications@github.com wrote:

Having this issue as well with Facebook on a local server.


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-41863826
.

@ktaras
Copy link

ktaras commented May 6, 2014

@ikanc I'm behind a proxy server. Can it cause problems? And if so, how can I configure it in my application?

@ikanc
Copy link

ikanc commented May 6, 2014

I am not familiar with VKontakte much, but I would suggest first to check
the SSL issue. if you can access SSL sites, it should be sufficient.
This usually happens when using WAMP/XAMPP and not enabling openssl or
disabling FW.

You can make sure that your PHP can open SSL sites with a simple
file_get_contents("https://www.facebook.com"); and dump it

Best Regards,
Ika Balzam, CTO | Net-Comet Development Studio | T: +65-9487-3791 |
ika@net-comet.com ika@net-comet.com | http://www.net-comet.com
http://www.net-comet.com

On Tue, May 6, 2014 at 7:23 PM, Taras notifications@github.com wrote:

@ikanc https://github.com/ikanc I'm behind a proxy server. Can it lead
to problems? And if so, how can I configure it in my application?


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-42291259
.

@ktaras
Copy link

ktaras commented May 6, 2014

@ikanc, have such result:

Warning: file_get_contents(): SSL: Connection reset by peer in ssl_test.php on line 2
Warning: file_get_contents(): Failed to enable crypto in ssl_test.php on line 2
Warning: file_get_contents(https://www.facebook.com): failed to open stream: operation failed in ssl_test.php on line 2

So, this is the problem, isn't it? Should I install and configure ssl for apache?

@ikanc
Copy link

ikanc commented May 6, 2014

Yes, although, the issue is not in your apache, but in the PHP.

Best Regards,
Ika Balzam, CTO | Net-Comet Development Studio | T: +65-9487-3791 |
ika@net-comet.com ika@net-comet.com | http://www.net-comet.com
http://www.net-comet.com

On Tue, May 6, 2014 at 7:56 PM, Taras notifications@github.com wrote:

@ikanc https://github.com/ikanc, have such result:

Warning: file_get_contents(): SSL: Connection reset by peer in ssl_test.php on line 2
Warning: file_get_contents(): Failed to enable crypto in ssl_test.php on line 2
Warning: file_get_contents(https://www.facebook.com): failed to open stream: operation failed in ssl_test.php on line 2

So, this is the problem, isn't it? Should I install and configure ssl for
apache?


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-42293595
.

@ktaras
Copy link

ktaras commented May 6, 2014

But in my phpinfo()
Registered Stream Socket Transports: tcp, udp, unix, udg, ssl, sslv3, tls
and openssl is enabled

@ktaras
Copy link

ktaras commented May 6, 2014

Wow! I found out what was the problem - I'm behind the proxy. Warnings disappeared and I got facebook page when I've configured proxy settings for file_get_contents().
So, I decided just to hardcode proxy settings configuration into StreamClient.php and it helped! I've got token and can make requests to API.
But I think that was not so good idea to hardcode proxy in StreamClient.php. Any ideas how to make it properly?

@cjasoni
Copy link

cjasoni commented May 9, 2014

I had same issue and i also fixed this problem by turning ON the allow_url_fopen at php.ini since we're using file_get_contents().

@elcct
Copy link

elcct commented Jun 3, 2014

None of solutions presented here have fixed the problem for me. I had to switch it to use CurlClient, which make it work.

I also think file_get_contents() should not be used - as the name suggests this is to load the content of a file, not make an API call.

I think you should remove StreamClient and use CurlClient by default.

@w3z315
Copy link

w3z315 commented Sep 18, 2014

@elcct Please provide a pull request or whatever for your solution.

It worked fine for me even online, but at some point it just stopped working..

@FeliciousX
Copy link

@elcct how exactly did you switch to CurlClient instead? :D

@FeliciousX
Copy link

@cyruxx in order to use CurlClient instead of the default, StreamClient , specifiy it before you call the OAuth::consumer() method.

Here's my example:-

public function loginWithBox()
{
...
$OAuth = new OAuth();
$OAuth::setHttpClient('CurlClient');
$box = $OAuth::consumer('Box');
...
}

Although this is abit old, I hope this helps for any future readers :)

@herlon214
Copy link

👍

@davidsneal
Copy link

@FeliciousX it helped me, thanks!

@FeliciousX
Copy link

@davidsneal welcome! Glad to be of help 😄

@akaramires
Copy link

@FeliciousX thank you!

@SerdarSanri
Copy link

I just found out that for Facebook, if you set your application Desktop application, token fails and you get the same error. After disabling Desktop/Native app checkbox everything worked fine.

@rrbailey89
Copy link

@FeliciousX @cyruxx where is the location of the file that those edits should be made? I cant find those lines of code anywhere :(

@FeliciousX
Copy link

@rrbailey89 anywhere on your codebase just before you call OAuth::consumer() as stated in my comment above

@rrbailey89
Copy link

@FeliciousX that's the thing I'm using phpbb 3.1.8 I have looked thru probably over 50 different files for that line of code and in not seeing it. I was hoping someone here might be able to tell me where the edit about be made.

This is the forum software I'm using https://www.phpbb.com/files/release/phpBB-3.1.8.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests