question

stanlywilsson avatar image
0 Likes"
stanlywilsson asked ·

Im getting error to get User token -- production

For days trying without success i'm stuck to be honnest so far is not easy to follow this api. Not very well documented with samples , I'm should be full example not only xml part. anyways here's my code please help: require_once(' keys.php'); $b64 = base64_encode($obj->app_id.':'.$obj->app_cert); curl_close ($ch); $code = 'v%5E1.1%23i%5E1%23p%5E3%23r%5E1%23f%5E0%23I%5E3%23t%5EUl41XzU6OENGMDcxMTAwMkFFODc4RDM5RTc2ODUxRjA3ODU0OUVfMV8xI0VeMjYw'; $request = 'grant_type=authorization_code&code='.$code.'&redirect_uri='.$obj->runame; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ' https://api.ebay.com/identity/v1/oauth2/token'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); $headers = array(); $headers[] = 'Content-Type = application/x-www-form-urlencoded'; $headers[] = "Authorization = Basic ".$b64; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $results = curl_exec($ch); echo $results; if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } The error is : {"error":"invalid_request","error_description":"request is missing a required parameter or malformed."} I don't know what I'm doing wrong, ....
token erroruser token
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

drybridgemedia avatar image
0 Likes"
drybridgemedia answered ·
@timneu - hope you got this sorted and weren't waiting on a response from eBay support!
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

timneu avatar image
0 Likes"
timneu answered ·
I have this same issue, but my headers are properly created with : characters. Thoughts @javed_developersupport? $client_id = 'apid'; $client_secret = 'secret'; $auth = base64_encode( $client_id . ':' . $client_secret ); $header = array( 'Content-Type: application/x-www-form-urlencoded', 'Authentication: Basic ' . $auth ); $grant = 'authorization_code'; $redUi = 'my Ru Name'; $code = 'my code'; $str = 'grant_type=' . $grant . '&redirect_uri=' . $redUi . '&code=' . $code; $ch = curl_init( ' https://api.ebay.com/identity/v1/oauth2/token' ); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $str ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $res = curl_exec( $ch );
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jakhtar_developersupport avatar image
0 Likes"
jakhtar_developersupport answered ·
Hi @stanlywilsson We have noticed you are using '=' in your header values whic is causing the error: $headers[] = 'Content-Type = application/x-www-form-urlencoded'; $headers[] = "Authorization = Basic ".$b64; When in fact, header values need to be correctly defined as shown below: $headers = [ 'Content-Type: application/x-www-form-urlencoded', 'Authorization: Basic '.base64_encode($appID.":".$certID) ]; Please let us know if this helps. Best Regards, eBay Developer Support
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.