PHP Classes

Problem with Discogs Oauth

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  Learn with a PHP OAut...  >  All threads  >  Problem with Discogs Oauth  >  (Un) Subscribe thread alerts  
Subject:Problem with Discogs Oauth
Summary:Changing to https doesn't work
Messages:12
Author:Crap Inhuman
Date:2016-02-08 00:20:45
 
  1 - 10   11 - 12  

  1. Problem with Discogs Oauth   Reply   Report abuse  
Picture of Crap Inhuman Crap Inhuman - 2016-02-08 00:20:45
Hi Manuel,

i have a problem with Oauth at Discogs. Discogs now use https instead of http.
I got the latest oauth api, and copied it to my web-server, but i got the following error message:

OAuth client error
Error: it was not possible to open the OAuth request token URL: 0 could not connect to the host "api.discogs.com"

OAuth client: Checking the OAuth token authorization state
OAuth client: The OAuth access token is not set
OAuth client: Requesting the unauthorized OAuth token
OAuth client: Accessing the OAuth request token at https://api.discogs.com/oauth/request_token
OAuth client: Error: it was not possible to open the OAuth request token URL: 0 could not connect to the host "api.discogs.com"

I try to explain my doing:
I have a vb-script (Discogs-Tagger from MediaMonkey), which send a http-post to my web-server:
germanc64.de/mm/oauth/oauth_guid.ph ...

The oauth_guid.php on the web-server do the authentication. Here is the importand content of it:

require('http.php');
require('oauth_client.php');

$client = new oauth_client_class;
$client->debug = true;
$client->debug_http = true;
$client->server = 'Discogs';
$f = $_GET["f"];
$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].
dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/oauth_guid.php?f=' . $f;

$client->client_id = 'otAQdlbdkiijJomXiHSS'; $application_line = __LINE__;
$client->client_secret = 'deleted';
$f = $_GET["f"];
if(($success = $client->Initialize()))
{
if(($success = $client->Process()))
{
$success = $client->CallAPI(
'https://api.discogs.com/oauth/identity',
'GET', array(), array('FailOnAccessError'=>true), $user);
}
$success = $client->Finalize($success);
}


Do you know what i do wrong? If i change the https:// into http://api.discogs.com it works great.

I hope you can help me, thank you in advance.

  2. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-02-08 00:42:54 - In reply to message 1 from Crap Inhuman
It seems your host may be blocking the fsockopen function.

Try forcing the use of Curl like this and let me know if it does not solve the problem.

$client->http_arguments['PreferCurl'] = true;

  3. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Crap Inhuman Crap Inhuman - 2016-02-08 01:19:30 - In reply to message 2 from Manuel Lemos
Thank you for the fast reply!

I added

$client->http_arguments['PreferCurl'] = true;

to the oauth_guid.php, but i got the following error message:


OAuth client error
Error: it was not possible to retrieve the OAuth request token: could not send the HTTP request: Could not execute the request: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

OAuth client: Checking the OAuth token authorization state
OAuth client: The OAuth access token is not set
OAuth client: Requesting the unauthorized OAuth token
OAuth client: Accessing the OAuth request token at https://api.discogs.com/oauth/request_token
OAuth client: Error: it was not possible to retrieve the OAuth request token: could not send the HTTP request: Could not execute the request: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure


I will ask my host tomorrow if fsockopen function is blocked.
I activated PHP Version 5.4. Should i use another version maybe?

Regards,

Sven

  4. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-02-08 03:30:22 - In reply to message 3 from Crap Inhuman
It seems your Curl installation is using SSL v3 which is now considered insecure. I think your host needs to at least enable TLS 1.0 support in Curl.

  5. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Crap Inhuman Crap Inhuman - 2016-02-08 04:49:43 - In reply to message 4 from Manuel Lemos
I just tested my ssl-support. The curl-version of my host have TLS support.

I tried to curl-connect to linkedin.com and it works.

I think it's a specific cipher, which discogs only accept.

I compared these 2 scans, the only thing i see, it's not SSLv3 problem.:
ssllabs.com/ssltest/analyze.html?d= ...

ssllabs.com/ssltest/analyze.html?d= ...

I wrote a support ticket to my host. Maybe he know what to do...

Greetings,
Sven

  6. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Crap Inhuman Crap Inhuman - 2016-02-08 05:32:22 - In reply to message 5 from Crap Inhuman
I just found the solution !

But i need your help. ;)

If I use this curl-php script:

<?php
function nxs_cURLTest($url, $msg, $testText){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSLVERSION, 'TLSv1_2');
$response = curl_exec($ch);
$errmsg = curl_error($ch);
$cInfo = curl_getinfo($ch);
curl_close($ch);
echo "Testing ... ".$url." - ".$cInfo['url']."<br />";
if (stripos($response, $testText)!==false)
echo "....".$msg." - OK<br />";
else
{
echo "....<b style='color:red;'>".$msg." - Problem</b><br /><pre>";
print_r($errmsg);
print_r($cInfo);
print_r(htmlentities($response));
echo "</pre>There is a problem with cURL. You need to contact your server admin or hosting provider.";
}
}

nxs_cURLTest("https://www.google.com/intl/en/contact/", "HTTPS to Google", "Mountain View, CA");
nxs_cURLTest("https://www.facebook.com/", "HTTPS to Facebook", 'id="facebook"');
nxs_cURLTest("https://www.discogs.com/", "HTTPS to API Discogs", 'get');
nxs_cURLTest("https://www.linkedin.com/nhome/", "HTTPS to LinkedIn", 'rel="canonical" href="https://www.linkedin.com/');

?>


The vip-line is here:
curl_setopt($ch, CURLOPT_SSLVERSION, 'TLSv1_2');

Without this option it doesn't work. Is it possible to add this option in the oauth_client.php?

  7. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-02-08 05:39:37 - In reply to message 6 from Crap Inhuman
That change needs to be done in the HTTP client class.

I think I will implement separate HTTP client code based on PHP fopen function, to not depend on the HTTP client class. Please hang on a moment while I do not implement that improvement.

  8. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Crap Inhuman Crap Inhuman - 2016-02-08 05:50:48 - In reply to message 7 from Manuel Lemos
This are great news! Thank you Manuel!


  9. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Crap Inhuman Crap Inhuman - 2016-02-11 22:30:50 - In reply to message 7 from Manuel Lemos
Hi Manuel,

my web hoster use the curl version 7.21.0 with openssl 0.9.8o
I just get the info from my web hoster, that an update of curl and openssl will be done soon, so my problem will be gone soon. :-)

  10. Re: Problem with Discogs Oauth   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-02-12 01:42:36 - In reply to message 9 from Crap Inhuman
That is good to know, but I will still add a new HTTP client code that will cause less problems to all users, as other people had problems due to their hosting environment.

 
  1 - 10   11 - 12