njasm / laravel5-soundcloud

Soundcloud API Service Provider For Laravel 5
MIT License
15 stars 9 forks source link

getting 401 Unauthorized when doing codeForToken exchange #5

Closed idanpt closed 9 years ago

idanpt commented 9 years ago

Hi there, maybe you have an idea why this is happening? i just do this: (after the user redirected back to my app with the code in the url) $soundcloud = new \Njasm\Soundcloud\SoundcloudFacade( Config::get('services.soundcloud.client_id'), Config::get('services.soundcloud.client_secret'), Config::get('services.soundcloud.redirect_uri') ); $soundcloud->codeForToken($request->code);

and get this response:

Response {#376 ▼ -httpVersion: "HTTP/1.1" -httpCode: "401" -httpCodeString: "Unauthorized\r" -response: """ HTTP/1.1 401 Unauthorized\r\n Access-Control-Allow-Headers: Accept, Authorization, Content-Type, Origin\r\n Access-Control-Allow-Methods: GET, PUT, POST, DELETE\r\n Access-Control-Allow-Origin: _\r\n Access-Control-Expose-Headers: Date\r\n Cache-Control: private, max-age=0, must-revalidate\r\n Date: Fri, 02 Oct 2015 15:08:11 GMT\r\n Server: am/2\r\n Content-Length: 0\r\n \r\n """ -info: array:26 [▼ "url" => "https://api.soundcloud.com/oauth2/token" "content_type" => null "http_code" => 401 "header_size" => 349 "request_size" => 484 "filetime" => -1 "ssl_verify_result" => 0 "redirect_count" => 0 "total_time" => 0.344 "namelookup_time" => 0.016 "connect_time" => 0.078 "pretransfer_time" => 0.25 "size_upload" => 244.0 "size_download" => 0.0 "speed_download" => 0.0 "speed_upload" => 709.0 "download_content_length" => 0.0 "upload_content_length" => 244.0 "starttransfer_time" => 0.344 "redirect_time" => 0.0 "redirect_url" => "" "primary_ip" => "93.184.220.127" "certinfo" => [] "primary_port" => 443 "local_ip" => "10.0.0.2" "localport" => 59460 ] -errno: 0 -errorString: "" -headers: array:8 [▼ "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" => "Fri, 02 Oct 2015 15:08:11 GMT" "Server" => "am/2" "Content-Length" => "0" ] -body: "" }

btw - i removed the deprecated ->asJson() here: old: $response = $this->post('/oauth2/token', $finalParams)->asJson()->request()->bodyObject(); new: $response = $this->post('/oauth2/token', $finalParams)->request()->bodyArray();

njasm commented 9 years ago

I'm looking into it. probably related to njasm/soundcloud#25

njasm commented 9 years ago

@idanpt update to the latest dev-master, the fix is working for other users, can you confirm that?

njasm commented 9 years ago

fix was tagged to version 2.2.3 on the main library repository.

You can use that stable version! thanks for reporting the issue!