cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error 401 retrieving token

I built at the beggining of this year a web application only for my personal purpouse to retrieve the values of recent sells from specific items and now I ran the project again and the authentication is not working anymore even if I didn't change the code and it's the first time I face this problem.

The code Im running is the following one:

public function obtenerAccessToken()
{
$clientId = config('services.ebay.client_id');
$clientSecret = config('services.ebay.client_secret');

$credentials = base64_encode($clientId . ':' . $clientSecret);

try {
Log::info('Retrieving eBay token');
$response = $this->client->post('https://api.ebay.com/identity/v1/oauth2/token', [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic ' . $credentials,
],
'form_params' => [
'grant_type' => 'client_credentials',
],
]);

$data = json_decode($response->getBody(), true);

if (isset($data['access_token'])) {
Log::info('Access token obtained succesfully: '. $data['access_token']);
return $data['access_token'];
} else {
Log::error('Error obtaining token: ' . print_r($data, true));
return null;
}
} catch (\Exception $e) {
Log::error('Exception: ' . $e->getMessage());
return null;
}
}
and Im getting the following error everytime Client error: `POST https://api.ebay.com/identity/v1/oauth2/token` resulted in a `401 Unauthorized` response:
{"error":"invalid_client","error_description":"client authentication failed"} 
I already double checked that the variables for the ClientID and Secrets are right and also refreshed the client Secret without any success. I don't know if during this period something changed to create the token...
Message 1 of 2
latest reply
1 REPLY 1

Re: Error 401 retrieving token

Hi @palingo92,

 

Thank you for your post!


We've reviewed your query, and to provide you with the best possible assistance, we need some additional information. Specifically, we require the API request you've made, the API response you received, and the rlogid found in the response headers. In relation to this, we kindly ask you to submit a support ticket through this link: eBay Support Tickets for assistance, which is a complimentary service. This will help us address your issue more effectively.


Additionally, please remember not to share these details here in the forum post, as they may contain confidential information that, if exposed, could lead to security concerns.


Best Regards,
eBay Developer Support

Message 2 of 2
latest reply