soundcloud /oauth2/token returning nothing but a 401 response - soundcloud

I noticed that some code I wrote using SoundcloudPHP stopped authenticating today, though it was working fine last time I used it a few days ago. To root out the problem, I've been trying to authenticate using the /oauth2/token endpoint but the response has been a 401 and empty body. I've been using the curl from the page at https://developers.soundcloud.com/docs/api/reference#token
From the command line:
curl -v -X POST "https://api.soundcloud.com/oauth2/token" -F 'client_id=MY_ID' -F 'client_secret=MY_SECRET' -F 'grant_type=authorization_code' -F 'redirect_uri=MY_REDIRECT' -F 'code=0000000EYAA1CRGodSoKJ9WsdhqVQr3g'
The response:
* About to connect() to api.soundcloud.com port 443 (#0)
* Trying 72.21.91.127... connected
* Connected to api.soundcloud.com (72.21.91.127) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
* subject: OU=Domain Control Validated; CN=*.soundcloud.com
* start date: 2014-04-22 16:52:12 GMT
* expire date: 2016-04-08 10:08:48 GMT
* subjectAltName: api.soundcloud.com matched
* issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Domain Validation CA - SHA256 - G2
* SSL certificate verify ok.
> POST /oauth2/token HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: api.soundcloud.com
> Accept: */*
> Content-Length: 658
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------e695cc6c8133
>
< HTTP/1.1 100 Continue
< HTTP/1.1 401 Unauthorized
< Access-Control-Allow-Headers: Accept, Authorization, Content-Type, Origin
< Access-Control-Allow-Methods: GET, PUT, POST, DELETE
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: Date
< Cache-Control: private, max-age=0, must-revalidate
< Date: Thu, 01 Oct 2015 23:25:25 GMT
< Server: am/2
< Content-Length: 0
<
* Connection #0 to host api.soundcloud.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
I've created new client tags to see if they'd work and I get the same thing. Since I'm using the curl provided in the docs I'd expect it to work. Any ideas?

I'm the creator of the php https://github.com/njasm/soundcloud library.
And the users of it reported the same problem, in fact what you say is also true that now, the curl examples on soundcloud don't work anymore (for some weird reason).
Investigating the issue to fix the library I've found what seems to be a content-type issue.
It seems that the content-type you need to use when requesting/refresh a token MUST always be application/x-form-urlencoded, and before we (the library) was working fine by communicating with a content-type of application/json.
If you are a user of my library, you should update to the latest master.
If you can help testing the fix, please report back to the issue page https://github.com/njasm/soundcloud/issues/25
Update:
It's confirmed the content type MUST be application/x-form-urlencoded
I'm conducting some test to confirm that this is in fact the case.
If so, I'll tag the commit to a stable release.
Good luck, and hope this helps!

I managed to resolve this issue for the Soundcloud API for Cocoa using the solution from #njsam
on SCSoundCloud.m, add these lines :
NSDictionary *customHeaderFields = [NSDictionary dictionaryWithObject:#"application/x-www-form-urlencoded" forKey:#"Content-Type"];
[config setObject:customHeaderFields forKey:kNXOAuth2AccountStoreConfigurationCustomHeaderFields];
your method should be like this:
+ (void)setClientID:(NSString *)aClientID
secret:(NSString *)aSecret
redirectURL:(NSURL *)aRedirectURL;
{
NSMutableDictionary *config = [NSMutableDictionary dictionary];
[config setObject:aClientID forKey:kNXOAuth2AccountStoreConfigurationClientID];
[config setObject:aSecret forKey:kNXOAuth2AccountStoreConfigurationSecret];
[config setObject:aRedirectURL forKey:kNXOAuth2AccountStoreConfigurationRedirectURL];
[config setObject:[NSURL URLWithString:kSCSoundCloudAuthURL] forKey:kNXOAuth2AccountStoreConfigurationAuthorizeURL];
[config setObject:[NSURL URLWithString:kSCSoundCloudAccessTokenURL] forKey:kNXOAuth2AccountStoreConfigurationTokenURL];
[config setObject:[NSURL URLWithString:kSCSoundCloudAPIURL] forKey:kSCConfigurationAPIURL];
NSDictionary *customHeaderFields = [NSDictionary dictionaryWithObject:#"application/x-www-form-urlencoded" forKey:#"Content-Type"];
[config setObject:customHeaderFields forKey:kNXOAuth2AccountStoreConfigurationCustomHeaderFields];
[[NXOAuth2AccountStore sharedStore] setConfiguration:config forAccountType:kSCAccountType];
}
Besides, we needed to update the OAuth2Client Library here to have support for kNXOAuth2AccountStoreConfigurationCustomHeaderFields
Hope this can help some people for IOS

Related

curl gnutls_handshake failed TLS connection was non-properly terminated

I would like to get the info from my custom Haystack service with the command
curl -v -X GET https://<myIP>:8443/api/haystack/about and it fails, the following is the log from above command
Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying <myproxy-ip>...
* Connected to proxy.example.com (myproxy-ip) port 911 (#0)
* Establish HTTP proxy tunnel to <myIP>:8443
> CONNECT <myIP>:8443 HTTP/1.1
> Host: <myIP>:8443
> User-Agent: curl/7.47.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied OK to CONNECT request
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 597 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* gnutls_handshake() failed: The TLS connection was non-properly terminated.
* Closing connection 0
curl: (35) gnutls_handshake() failed: The TLS connection was non-properly terminated.
At the same time, the Haystack service is having a front end web portal, when I access with Chrome, I can see the warning Privacy Error and NET::ERR_CERT_AUTHORITY_INVALID, but i still can proceed on the browser. I guess this might be the reason causing my curl fail.
Any idea?
Thanks

Facebook Object Debugger Error 502 and Error parsing input URL

Well, this website uses AWS EC2, and right now when i shared the site on Facebook, facebook don't show nothing, but yesterday it work well.
Right now the Facebook lint(object debugger) says
Error parsing input URL, no data was cached, or no data was scraped.
And
Curl Error : RECV_ERROR Received HTTP code 502 from proxy after
CONNECT
But when i use curl via terminal on my Mac (like curl -v -X TRACE www.cuinzy.com) this return:
* Rebuilt URL to: www.cuinzy.com/
* Hostname was NOT found in DNS cache
* Trying 54.207.48.99...
* Connected to www.cuinzy.com (127.0.0.1) port 80 (#0)
> TRACE / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: www.cuinzy.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 17 Aug 2015 10:14:36 GMT
* Server Apache is not blacklisted
< Server: Apache
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: message/http
<
TRACE / HTTP/1.1
User-Agent: curl/7.37.1
Host: www.cuinzy.com
Accept: */*
* Closing connection 0
Curl return response code 200 on www.cuinzy.com, and if try with url https://www.cuinzy.com/itm/572-aumento-natural-del-busto-pueraria-mirifica-100-x-500mg.html, this return:
* Hostname was NOT found in DNS cache
* Trying 54.207.48.99...
* Connected to www.cuinzy.com (127.0.0.1) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
* Server certificate: *.cuinzy.com
* Server certificate: COMODO RSA Domain Validation Secure Server CA
* Server certificate: COMODO RSA Certification Authority
* Server certificate: AddTrust External CA Root
> TRACE /itm/572-aumento-natural-del-busto-pueraria-mirifica-100-x-500mg.html HTTP/1.1
> User-Agent: curl/7.37.1
> Host: www.cuinzy.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 17 Aug 2015 10:16:25 GMT
* Server Apache is not blacklisted
< Server: Apache
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: message/http
<
TRACE /itm/572-aumento-natural-del-busto-pueraria-mirifica-100-x-500mg.html HTTP/1.1
User-Agent: curl/7.37.1
Host: www.cuinzy.com
Accept: */*
* Closing connection 0
And look how the use of SSL does not represent a change, additionally, notice that at all times the http response code is 200.
And, if i click on See exactly what our scraper sees for your URL link of Facebook Lint, this only return:
Document returned no data
Ah, additionally, i try this tools(and all return http response code 200 and work fine):
curl via terminal on mac
http://httpstatus.io/
http://iframely.com/debug?uri=https%3A%2F%2Fwww.cuinzy.com%2Fitm%2F572-aumento-natural-del-busto-pueraria-mirifica-100-x-500mg.html
http://opengraphcheck.com/result.php?url=https%3A%2F%2Fwww.cuinzy.com%2Fitm%2F572-aumento-natural-del-busto-pueraria-mirifica-100-x-500mg.html#.VdG3hVN_Oko
https://coveloping.com/tools/open-graph-tag-tester
Please, if you know whats happend tell me, i dont understand...
P.S: sorry for my bad english.

Is Paypal Sandbox offline?

Sorry for asking here, but this is a bit of an emergency and I know from past experience, it could take more than 7 days to get a response from Paypal.
I am working on a project that, about 10 days ago, was working fine. 2 Days ago I returned to the PP portion and all of a sudden, I am getting no response from Paypal.
This is the URL I am calling:
https://api.sandbox.paypal.com/v1/payments/payment
And absolutely no response is being returned. I'm certain that before it at least returned an error if no parameters are included. But now, nothing at all with or without parameters.
Paypal does have a status page for the live site. Not sure if it still extends to the sandbox, tho. There was a major outage on the live end yesterday.
Which API are you using?
Do you still have issues with this? It's working fine for me. I don't believe we had an outage either.
$ curl -v https://api.sandbox.paypal.com/v1/payments/payment
* About to connect() to api.sandbox.paypal.com port 443 (#0)
* Trying 23.43.75.39...
* connected
* Connected to api.sandbox.paypal.com (23.43.75.39) port 443 (#0)
*a lot of SSL stuff*
> GET /v1/payments/payment HTTP/1.1
> User-Agent: curl/7.28.1
> Host: api.sandbox.paypal.com
> Accept: */*
>
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< Paypal-Debug-Id: 7177ce39c4142
< Content-Type: application/json
< Content-Length: 0
< DC: origin1-api.sandbox.paypal.com
< Date: Sun, 03 Nov 2013 12:07:31 GMT
< Connection: keep-alive
< Set-Cookie: DC=origin1-api.sandbox.paypal.com; secure
<
* Connection #0 to host api.sandbox.paypal.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
Note the HTTP 401 response (because I didn't specify a valid Authorization header with an access token for the request).

Managing international users

There are three major problems with the collection of payments:
Our company deals with Hungarian products, including the product description of accented characters are. The new RestAPI can successfully manage the payments to resolve the first round, but I can not accented characters to pass the paypal server.
If HTML.Encoding I'm using, the cipher text will be displayed on the checkout page does not decode the Paypal server. (Environment: Windows, .NET, C#)
So:
1. How do I use accented characters with the name of items?
Update:
I tried UTF8 as follows:
1.1. get the access token:
curl https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Content-Type: charset=UTF-8" \
-H "Accept-Language: hu_HU" \
-u "EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp" \
-d "grant_type=client_credentials"
1.2. answer:
{"scope":"openid https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card/.* https://api.paypal.com/v1/vault/credit-card
https://api.paypal.com/v1/developer/.*",
"access_token":"5tz416Qgym8Si9RM0nBS4DNSrGRFCMu5vZ923s--hLM",
"token_type":"Bearer",
"app_id":"APP-8KK24973T6066201W",
"expires_in":28800
}
1.3. The content json (I saved as UTF-8 text file with notepad with name 'content-utf8.json')
{
"intent":"sale",
"redirect_urls":{
"return_url":"http://example.com/your_redirect_url/",
"cancel_url":"http://example.com/your_cancel_url/"
},
"payer":{
"payment_method":"paypal"
},
"transactions":[
{
"amount":{
"total":"7.47",
"currency":"USD"
},
"description":**"Árvíztűrő tükörfúrógépes tanfolyam"**
}
]
}
1.4. Send the payment
curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H 'Content-Type:application/json; charset=utf-8' \
-H 'Authorization:Bearer 5tz416Qgym8Si9RM0nBS4DNSrGRFCMu5vZ923s--hLM' \
--data 'content-utf8.json'
1.5. The answer
* Adding handle: conn: 0x1385f58
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1385f58) send_pipe: 1, recv_pipe: 0
* About to connect() to api.sandbox.paypal.com port 443 (#0)
* Trying 23.42.27.39...
* Connected to api.sandbox.paypal.com (23.42.27.39) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files\Git\bin\curl-ca-bundle.crt
CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-SHA
* Server certificate:
* subject: C=US; ST=CALIFORNIA; L=San Jose; O=PayPal, Inc.; OU=Partner Su
pport; CN=api.sandbox.paypal.com
* start date: 2013-08-20 00:00:00 GMT
* expire date: 2015-08-21 23:59:59 GMT
* subjectAltName: api.sandbox.paypal.com matched
* issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of
use at https://www.verisign.com/rpa (c)10; CN=VeriSign Class 3 Secure Server CA
- G3
* SSL certificate verify ok.
> POST /v1/payments/payment HTTP/1.1
> User-Agent: curl/7.30.0
> Host: api.sandbox.paypal.com
> Accept: */*
> Content-Type:application/json; charset=utf-8
> Authorization:Bearer 5tz416Qgym8Si9RM0nBS4DNSrGRFCMu5vZ923s--hLM
> Content-Length: 12
>
* upload completely sent off: 12 out of 12 bytes
< HTTP/1.1 400 Bad Request
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< PayPal-Debug-Id: eb749926be259
< Content-Type: application/json;charset=UTF-8
< Content-Length: 200
< DC: origin2-api.sandbox.paypal.com
< Date: Tue, 15 Oct 2013 09:03:52 GMT
< Connection: close
< Set-Cookie: DC=origin2-api.sandbox.paypal.com; secure
<
{"name":"MALFORMED_REQUEST",
"message":"The request JSON is not well formed.",
"information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST",
"debug_id":"eb749926be259"}
* Closing connection 0
* SSLv3, TLS alert, Client hello (1):
The bottom line:
**MALFORMED_REQUEST: The request JSON is not well formed.**
+++
We plan to our customers from different countries, so it would be nice if paying by PayPal page (if supported by the language) would be displayed in their language.
2. How do I solve it as returned by Paypal approval_url page displayed in English/Hungarian (or any other language supported by paypal)?
When paying customers redirected to the PayPal site where you can pay with credit card, you should fill in a few fields (firstname, lastname, address, phone, etc). Tulum would be nice if we could retrieve these fields forward data.
+++
3. How do I get through the PayPal RestAPI (or otherwise) to send client data to the server before the PayPal payment?
Any help is appreciated!
Paypal accepts only UTF-8. I've not tried Hungarian languages, but UTF-8 will cover that. Make sure all your calls are encoded that way and they should go through.
Paypal will likely show them pages in the closest language to them. I don't see Hungarian explicitly listed in in the LOCALECODEs listed on this page. Sorry I can't be of more help here.
As to how to send data to Paypal, I find CURL works really well for this.

Paypal Refund Transaction Refused

I making refund option with PayPal REST API on my site.
I make order with Paypal test account all taht works great, but when I try to refund i get "Transaction refused". I try refunding full amount, part amount, currency changes... nothing helped me. I also try with new orders and some older orders ( 2 days old) same.
Here what I run and what I get
curl -v https://api.sandbox.paypal.com/v1/payments/sale/*******/refund -H 'Content-Type:application/json' -H 'Authorization: Bearer ***********' -d '{"amount":{"total":"5.00","currency":"JPY"}}'
* About to connect() to api.sandbox.paypal.com port 443 (#0)
* Trying 173.0.82.78...
* Connected to api.sandbox.paypal.com (173.0.82.78) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* NSS: client certificate not found (nickname not specified)
* SSL connection using SSL_RSA_WITH_3DES_EDE_CBC_SHA
* Server certificate:
* subject: CN=api.sandbox.paypal.com,OU=PayPal Production,O="PayPal, Inc.",L=San Jose,ST=California,C=US
* start date: Dec 06 00:00:00 2012 GMT
* expire date: Dec 06 23:59:59 2016 GMT
* common name: api.sandbox.paypal.com
* issuer: CN=VeriSign Class 3 Secure Server CA - G3,OU=Terms of use at https:// www.verisign.com/rpa (c)10,OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US
> POST /v1/payments/sale/**********/refund HTTP/1.1
> User-Agent: curl/7.29.0
> Host: api.sandbox.paypal.com
> Accept: */*
> Content-Type:application/json
> Authorization: Bearer ******************
> Content-Length: 44
>
* upload completely sent off: 44 out of 44 bytes
< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Date: Sun, 25 Aug 2013 21:35:55 GMT
< Connection: close
< PayPal-Debug-Id: 6ccd19f66d117
< Content-Type: application/json
< Content-Length: 171
< Connection: close
<
* Closing connection 0
{"name":"TRANSACTION_REFUSED","message":"{0}","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#TRANSACTION_REFUSED","debug_id":"6ccd19f66d117"}
So what can be problem? I check link about that PayPal give me and he didnt help me at all.
I need to make refund option working ASAP.
The original transactions were run in Japanese Yen (JPY), but you don't have a JPY balance in your PayPal account -- hence, all of the transactions you've run in JPY are sitting in 'unclaimed' status. Log in to the seller's account (https://www.sandbox.paypal.com) and go to Profile->My Money. Under More (next to PayPal balance), click Currencies. Then, under the Select new currency drop-down, choose Japanese Yen and click Add Currency. The transactions you've previously taken should begin funneling into the account within a few minutes, after which you should be able to process your refund.