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

negotiation/v1/find_eligible_items call doesn't accept a valid authorization token

Hello,

 

I am trying to get the set of IDs that are eligible for a seller-initiated discount offer to a buyer by calling GET https://api.ebay.com/sell/negotiation/v1/find_eligible_items as per https://developer.ebay.com/api-docs/sell/negotiation/resources/offer/methods/findEligibleItems.

 

Here is my code: 

headers = {
                    'Authorization' : "Bearer " + userAccessToken,
                    'X-EBAY-C-MARKETPLACE-ID' : 'EBAY_US'
}
 response = requests.get( url, headers = headers )
 
userAccessToken is created with the authorization code grant flow. It is valid as I am able to use it to make Marketing API calls. I've also tried my Auth'n'Auth and OAuth user access tokens.
 
Scopes https://api.ebay.com/oauth/api_scope/sell.inventory.readonly and https://api.ebay.com/oauth/api_scope/sell.inventory are available to my application as per the Application Keys page.
 
The error I am getting is {"errors": [ { "errorId": 1001, "domain": "OAuth", "category": "REQUEST", "message": "Invalid access token", "longMessage": "Invalid access token. Check the value of the Authorization HTTP request header." }]\n}
 
What am I doing wrong? 
 
I appreciate your help.
 
Best regards,
 
 
 
 
 
 
       

 

 

 

Message 1 of 3
latest reply
2 REPLIES 2

Re: negotiation/v1/find_eligible_items call doesn't accept a valid authorization token

Are you sure you're generating a User Access Token and not an Application Access token? The Marketplace API expects a GET which is generally associated with 'Application access' credentials.

"Application tokens are general-use tokens that give access to interfaces that return application data. For example, many GET requests require only an Application token for authorization."

https://developer.ebay.com/api-docs/static/oauth-token-types.html#:~:text=For%20example%2C%20many%20....

Here's my working example (tested with a User Access Token):

 

<?php

function findEligibleItems($UserAccessToken) {

    $headers = array(
        'Authorization: Bearer ' . $UserAccessToken,
        'X-EBAY-C-MARKETPLACE-ID: EBAY_US',
        'Content-Type: application/json'
    );

    $params = array(
        'limit' => '100'
    );
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.ebay.com/sell/negotiation/v1/find_eligible_items?' . http_build_query($params));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return $response;
}

$UserAccessToken = file_get_contents('token.txt');  // put user access token in text file
$find = findEligibleItems($UserAccessToken);
var_dump($find);

 

 

Message 2 of 3
latest reply

Re: negotiation/v1/find_eligible_items call doesn't accept a valid authorization token

Python version, also tested and working:

def findEligibleItems():

    headers = {
        'Authorization': 'Bearer ' + UserAccessToken,
        'X-EBAY-C-MARKETPLACE-ID': 'EBAY_US',
        'Content-Type': 'application/json',
    }
    params = {
        'limit': '100',
    }

    response = requests.get('https://api.ebay.com/sell/negotiation/v1/find_eligible_items',
        params=params, headers=headers)

 

 

Message 3 of 3
latest reply