Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you properly call getPrivileges? Got error: TypeError: eBay.sell.getPrivileges is not a function #49

Closed
doverradio opened this issue Mar 23, 2021 · 4 comments

Comments

@doverradio
Copy link

Hi,

I want to know the seller limits for an account so I tried to call getPrivileges but got this error:
Got error: TypeError: eBay.sell.getPrivileges is not a function

My code:

exports.getSellerLimits = async (req, res) => {  
  let {        
    ebayAuthToken,
    } = req.body


    eBay.auth.oAuth2.setScope([
      'https://api.ebay.com/oauth/api_scope',
      'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
      'https://api.ebay.com/oauth/api_scope/sell.fulfillment',
      'https://api.ebay.com/oauth/api_scope/sell.account',
      'https://api.ebay.com/oauth/api_scope/sell.account.readonly'
  ]);
    
    eBay.auth.oAuth2.setCredentials(ebayAuthToken);
  
    try {
    let result = await eBay.sell.getPrivileges()

    console.log('result...')
    console.log(result)
    res.json(result)

    }
    catch(e) {
      console.log(`Got error: `, e)
      res.json({error: e})
    }
    

}

How do you make this call?

@olliechick
Copy link
Contributor

I think you need to do eBay.sell.account.getPrivileges()

@doverradio
Copy link
Author

doverradio commented Mar 23, 2021

Thanks olliechick.

I got a different result after making the change.

However, it resulted in a new error:

     data:
      { error: 'invalid_scope',
        error_description:
         'The requested scope is invalid, unknown, malformed, or exceeds the scope granted to the client' } }, 

I checked the getPrivileges ebay documentation and it says to use these oAuth scopes, which I thought I had done:

https://api.ebay.com/oauth/api_scope/sell.account
https://api.ebay.com/oauth/api_scope/sell.account.readonly

In fact, when double checking, I have done this now but it still gives error that requested scope is invalid...:

    eBay.auth.oAuth2.setScope([
      'https://api.ebay.com/oauth/api_scope',
      'https://api.ebay.com/oauth/api_scope/sell.account',
      'https://api.ebay.com/oauth/api_scope/sell.account.readonly'
  ]);

Were you able to successfully make this call before? If so, please share how. Thank you!

@doverradio
Copy link
Author

Nevermind, I solved it another way...


exports.getSellerLimits = async (req, res) => {  
  let {        
    ebayAuthToken,
    } = req.body

    if(ebayAuthToken == null) {
      res.status(400).json({error: `Missing ebay auth token.  Please try again with ebay auth token.`})
    }
   
    let result = await fetch(
      `https://api.ebay.com/sell/account/v1/privilege`, 
      {
        method: "GET",
        headers: {
          Authorization: `Bearer ${ebayAuthToken}`,
          Accept: "application/json",
          "Content-Type": "application/json"
        }
      }
      )


      let sellerPrivileges = await result.json()

      res.json(sellerPrivileges)


}


@dantio
Copy link
Collaborator

dantio commented Mar 24, 2021

@olliechick has the correct answer. Check out the example: https://github.com/hendt/ebay-api/blob/next/examples/restful/sell/getPrivileges.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants