简体   繁体   English

NodeJS hendt/ebay-api / getOrders / 错误 - 权限不足,无法完成请求

[英]NodeJS hendt/ebay-api / getOrders / Error - Insufficient permissions to fulfill the request

So I am using the hendt/ebay-api library but having no success with the getOrders call.所以我正在使用hendt/ebay-api 库,但 getOrders 调用没有成功。

Here's the auth scopes I'm using when setting the ORIGINAL User access token...:这是我在设置原始用户访问令牌时使用的身份验证范围...:

      eBay.auth.oAuth2.setScope([
        'https://api.ebay.com/oauth/api_scope',
        'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
        'https://api.ebay.com/oauth/api_scope/sell.marketing',
        'https://api.ebay.com/oauth/api_scope/sell.inventory.readonly',
        'https://api.ebay.com/oauth/api_scope/sell.inventory',
        'https://api.ebay.com/oauth/api_scope/sell.account',
        'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
        '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.analytics.readonly',
        'https://api.ebay.com/oauth/api_scope/sell.finances',
        'https://api.ebay.com/oauth/api_scope/sell.payment.dispute',
        'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
    ]);

Here's my code (ExpressJS backend controller method...):这是我的代码(ExpressJS 后端 controller 方法...):

exports.getOrders = async (req, res) => { 
  let  _id = req.params.userId; // user's _id
  let token = await refreshEbayToken(_id, eBay)
  console.log(`token...`, token) // not an array!  It's an object!

  // set OAuth2 eBay credentials
  eBay.auth.oAuth2.setCredentials(token.access_token);

  try {
    let result = await eBay.sell.fulfillment.getOrders({
      filter: 'orderfulfillmentstatus:{NOT_STARTED|IN_PROGRESS}',
        limit: 5
    })
    console.log(`Got a result...`, result)
    res.json(result)
  } catch (e) {
    console.log(`Got an error in getOrders...`, e)
    res.status(400).json( { error: e } )
  }
  
}

Here's the error I get:这是我得到的错误:

{
        "meta": {
            "errors": [
                {
                    "errorId": 1100,
                    "domain": "ACCESS",
                    "category": "REQUEST",
                    "message": "Access denied",
                    "longMessage": "Insufficient permissions to fulfill the request."
                }
            ]
        },
        "name": "EBayAccessDenied"
    }

Even freshly minted User access tokens through those scopes get this error.即使是通过这些范围新创建的用户访问令牌也会出现此错误。

According to the ebay docs on getOrders , these are the required auth scopes for this call:根据getOrders 上的 ebay 文档,这些是此调用所需的身份验证范围:

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

Upon further investigation, I found I am certainly using those scopes in the response (below is a snippet of the scopes grabbed from the larger ebay error)...经过进一步调查,我发现我肯定在响应中使用了这些范围(下面是从较大的 ebay 错误中获取的范围的片段)...

...%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.fulfillment.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.fulfillment%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.analytics.readonly%20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.finances%20...

As shown above, I am clearly using the sell.fulfillment and sell.fulfillment.readonly scopes so I do not understand what is the issue.如上所示,我显然在使用sell.fulfillmentsell.fulfillment.readonly范围,所以我不明白问题出在哪里。

What do you think could be the issue?您认为可能是什么问题?

So I am using the library but having no success with the getOrders call.所以我正在使用该库,但 getOrders 调用没有成功。

Here's the auth scopes I'm using when setting the ORIGINAL User access token这是我在设置原始用户访问令牌时使用的身份验证范围

https://gist.github.com/mudassaralichouhan/d952b464b2907c7f833c87c05152eb76 https://gist.github.com/mudassaralichouhan/d952b464b2907c7f833c87c05152eb76

I finally got it working.我终于让它工作了。

Here is an example of what I receive now:这是我现在收到的示例:

{
    "sales": [
        {
            "orderId": "xxxxxxxxx",
            "legacyOrderId": "xxxxxxxxx-xxxxxxxxx",
            "creationDate": "2022-03-09T23:10:36.000Z",
            "lastModifiedDate": "2022-03-18T15:51:04.000Z",
            "orderFulfillmentStatus": "FULFILLED",
            "orderPaymentStatus": "PAID",
            "sellerId": "xxxx",
            "buyer": {
                "username": "xxxxx",
                "taxAddress": {
                    "stateOrProvince": "xx",
                    "postalCode": "xxxxxxxx",
                    "countryCode": "xx"
                }
            },
            "pricingSummary": {
                "priceSubtotal": {
                    "value": "xxxxx",
                    "currency": "USD"
                },
                "deliveryCost": {
                    "value": "0.0",
                    "currency": "USD"
                },
                "total": {
                    "value": "xxxxx",
                    "currency": "USD"
                }
            },
            "cancelStatus": {
                "cancelState": "NONE_REQUESTED",
                "cancelRequests": []
            },
            "paymentSummary": {
                "totalDueSeller": {
                    "value": "xxxxx",
                    "currency": "USD"
                },
                "refunds": [],
                "payments": [
                    {
                        "paymentMethod": "EBAY",
                        "paymentReferenceId": "xxxxxx",
                        "paymentDate": "2022-03-09T23:15:33.109Z",
                        "amount": {
                            "value": "xxxxxxxx",
                            "currency": "USD"
                        },
                        "paymentStatus": "PAID"
                    }
                ]
            },
            "fulfillmentStartInstructions": [
                {
                    "fulfillmentInstructionsType": "SHIP_TO",
                    "minEstimatedDeliveryDate": "2022-03-14T07:00:00.000Z",
                    "maxEstimatedDeliveryDate": "2022-03-19T07:00:00.000Z",
                    "ebaySupportedFulfillment": false,
                    "shippingStep": {
                        "shipTo": {
                            "fullName": "xxxxxxxxxx",
                            "contactAddress": {
                                "addressLine1": "xxxxxxxxxxx",
                                "city": "xxxxxxxxxx",
                                "stateOrProvince": "xx",
                                "postalCode": "xxxxxxxxx",
                                "countryCode": "US"
                            },
                            "primaryPhone": {
                                "phoneNumber": "xxxxxxxxxxxxx"
                            },
                            "email": "xxxxxxxxxxxx@members.ebay.com"
                        },
                        "shippingServiceCode": "ShippingMethodStandard"
                    }
                }
            ],
            "fulfillmentHrefs": [
                "https://api.ebay.com/sell/fulfillment/v1/order/xxxxxxxxxxx/shipping_fulfillment/xxxxxxxxxx"
            ],
            "lineItems": [
                {
                    "lineItemId": "xxxxxxxxxx",
                    "legacyItemId": "xxxxxxxxxx",
                    "legacyVariationId": "xxxxxxxxxx",
                    "sku": "xxxxxxxxxx",
                    "title": "xxxxxxxxxx",
                    "lineItemCost": {
                        "value": "xxxxxxxxxx",
                        "currency": "USD"
                    },
                    "quantity": 1,
                    "soldFormat": "FIXED_PRICE",
                    "listingMarketplaceId": "EBAY_US",
                    "purchaseMarketplaceId": "EBAY_US",
                    "lineItemFulfillmentStatus": "FULFILLED",
                    "total": {
                        "value": "xxxxxxxxxx",
                        "currency": "USD"
                    },
                    "deliveryCost": {
                        "shippingCost": {
                            "value": "0.0",
                            "currency": "USD"
                        }
                    },
                    "appliedPromotions": [],
                    "taxes": [],
                    "ebayCollectAndRemitTaxes": [
                        {
                            "taxType": "STATE_SALES_TAX",
                            "amount": {
                                "value": "xxxxxxxxxx",
                                "currency": "USD"
                            },
                            "collectionMethod": "NET"
                        }
                    ],
                    "properties": {
                        "buyerProtection": true
                    },
                    "lineItemFulfillmentInstructions": {
                        "minEstimatedDeliveryDate": "2022-03-14T07:00:00.000Z",
                        "maxEstimatedDeliveryDate": "2022-03-19T07:00:00.000Z",
                        "shipByDate": "2022-03-14T06:59:59.000Z",
                        "guaranteedDelivery": false
                    },
                    "itemLocation": {
                        "location": "xxxxxxxxxx",
                        "countryCode": "US",
                        "postalCode": "xxxxxxxxxx"
                    }
                }
            ],
            "ebayCollectAndRemitTax": true,
            "salesRecordReference": "xxxxxxxxxx",
            "totalFeeBasisAmount": {
                "value": "xxxxxxxxxx",
                "currency": "USD"
            },
            "totalMarketplaceFee": {
                "value": "xxxxxxxxxx",
                "currency": "USD"
            }
        }
    ]
}

Here are my scopes:这是我的范围:

      eBay.auth.oAuth2.setScope([
        'https://api.ebay.com/oauth/api_scope',
        'https://api.ebay.com/oauth/api_scope/sell.marketing.readonly',
        'https://api.ebay.com/oauth/api_scope/sell.marketing',
        'https://api.ebay.com/oauth/api_scope/sell.inventory.readonly',
        'https://api.ebay.com/oauth/api_scope/sell.inventory',
        'https://api.ebay.com/oauth/api_scope/sell.account',
        'https://api.ebay.com/oauth/api_scope/sell.account.readonly',
        '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.analytics.readonly',
        'https://api.ebay.com/oauth/api_scope/sell.finances',
        'https://api.ebay.com/oauth/api_scope/sell.payment.dispute',
        'https://api.ebay.com/oauth/api_scope/commerce.identity.readonly',
    ]);

Here is the code getting it right ( express.js )...这是正确的代码(express.js)...

    exports.getOrders = async (req, res) => {  // https://developer.ebay.com/Devzone/XML/docs/Reference/eBay/GetOrders.html

      let  _id = req.params.userId; // user's _id
      let a = {}
      a._id = _id
      a.userDoc = await User.findById( { _id: a._id } )
      eBay.auth.oAuth2.setCredentials( a.userDoc.token[ 0 ] ) // set OAuth2 eBay credentials
      try 
      {
        a.result = await eBay.trading.getOrders({
          filter: 'orderfulfillmentstatus:{NOT_STARTED|IN_PROGRESS}',
            limit: 5
        })
        console.log(`Got a result...`, a.result)
        } catch ( e ) {
      }
    }

I send in the mongodb user _id as request params and use that to pull out their user token, which is passed into eBay.auth.oAuth2.setCredentials( a.userDoc.token[ 0 ] ) and allows the call to actually be made... eBay.trading.getOrders我发送 mongodb 用户_id作为请求参数并使用它来提取他们的用户令牌,该令牌被传递到eBay.auth.oAuth2.setCredentials( a.userDoc.token[ 0 ] )并允许实际进行调用。 .. eBay.trading.getOrders

I hope this helps someone out there.我希望这可以帮助那里的人。 I remember being unable to make this call for months.我记得几个月都无法拨打这个电话。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 E Bay API 调用错误“权限不足,无法满足请求” - E Bay API call Error "Insufficient permissions to fulfill the request" 为什么谷歌浏览器会为ajax get ebay-api端点提供错误的未知网址方案 - Why does google chrome give error unknown url scheme for ajax get request to ebay-api endpoint 易趣贸易 API 获取项目 Ajax 请求 - Ebay Trading API Get Item Ajax Request eBay交易API addFixedPriceItem调用错误 - eBay Trading API addFixedPriceItem Call Error 添加 Firestore 规则“&& request.auth.uid == userId;” 导致“快照侦听器错误:FirebaseError:缺少或权限不足。” - Adding Firestore rule "&& request.auth.uid == userId;" results in"Error in snapshot listener: FirebaseError: Missing or insufficient permissions." 快照侦听器中未捕获的错误:FirebaseError:缺少权限或权限不足 - Uncaught Error in snapshot listener: FirebaseError: Missing or insufficient permissions nodejs 和 twitter api 错误'错误:错误 Twitter 流式传输请求:404' - nodejs and twitter api error ' Error: Bad Twitter streaming request: 404 ' 退出 Firebase React 应用程序时出现“权限不足”错误 - “Insufficient permissions” error when signing out of Firebase React app Firestore 安全规则错误:FirebaseError:缺少权限或权限不足 - Error with Firestore security rules: FirebaseError: Missing or insufficient permissions Firebase onSnapshot 中未捕获的错误:[FirebaseError:缺少权限或权限不足。] - Firebase Uncaught Error in onSnapshot: [FirebaseError: Missing or insufficient permissions.]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM