geraldtscharre avatar image
1 Like"
geraldtscharre asked

Ebay API call AddItem throws error 931 - Invalid auth token

'm working on an iOS app for selling items on Ebay with the Ebay Trading api. Have been successfully gone through the steps as described on the ebay developer site: 1) created an ebay developer account 2) registered my app 3) got the API-keys, developer certificates and client secrets (for sandbox and production) 4) created a testuser for the sandbox environment 5) Gone through the authorization process and received the authorization code for the testuser 6) Sent a request for a usertoken and successfully received it (for sandbox). Here's the code (works fine): Get token (iOS, Swift 3) func GetEbayUsertoken() { let urlstring = GlobalVar.ebay_accesstokenlink let url = URL(string: urlstring) var access_token: String = "" // create the authorization parameter let loginString = NSString(format: "%@:%@", GlobalVar.ebay_appid, GlobalVar.ebay_certid) let loginData: Data = String.Encoding.utf8.rawValue)! let base64LoginString = loginData.base64EncodedString(options: NSData.Base64EncodingOptions()) // compose header var headers = Alamofire.SessionManager.defaultHTTPHeaders headers["Content-Type"] = "application/x-www-form-urlencoded" headers["Authorization"] = "Basic " + base64LoginString // compose query parameters let parameters = [ "grant_type" : "authorization_code", "code" : GlobalVar.ebay_authorization_code, "redirect_uri" : GlobalVar.ebay_redirect_uri ] as [String : Any] Alamofire.request(url!, method: .post, parameters: parameters, encoding: URLEncoding.httpBody, headers: headers).responseJSON { response in switch response.result { case .success: let jsonData = NSData(base64Encoded: ( NSData.Base64EncodingOptions()))!, options:NSData.Base64DecodingOptions(rawValue: 0)) let json = JSON(data: jsonData as! Data) access_token = json["access_token"].stringValue if access_token != "" { GlobalVar.ebay_usertoken = access_token // get expiration date of usertoken let calendar = Calendar.current GlobalVar.ebay_usertoken_expires = .second, value: json["expires_in"].intValue, to: Date()) // get refresh token and it's expiration datetime GlobalVar.ebay_refreshtoken = json["refresh_token"].stringValue GlobalVar.ebay_refreshtoken_expires = .second, value: json["refresh_token_expires_in"].intValue, to: Date()) self.SaveEbayTokens() } else { GlobalVar.ebay_usertoken = "" GlobalVar.ebay_usertoken_expires = nil GlobalVar.ebay_refreshtoken = "" GlobalVar.ebay_refreshtoken_expires = nil } case .failure: // needs to be handled!! GlobalVar.ebay_usertoken = "" GlobalVar.ebay_usertoken_expires = nil GlobalVar.ebay_refreshtoken = "" GlobalVar.ebay_refreshtoken_expires = Nil self.SaveEbayTokens() } } } With this call I'm receiving a token that looks like: v^1.1#i^1#r^0#p^3#I^3#f^ ... BwEQAA Now here comes the problem: With this token I tried to make an AddItem-call in the sandbox environment (using the Google-Chrome DHC-Extension), in order to check out if everything works as expected, but I'm receiving the following error code: 931 - Invalid auth token Validation of the authentication token in API request failed Here's my request: REQUEST:, Method: Post HEADERS: Content-Type: text/XML X-EBAY-API-COMPATIBILITY-LEVEL: 971 X-EBAY-API-CALL-NAME: AddItem X-EBAY-API-SITEID: 0 X-EBAY-API-APP-NAME: xxxxx X-EBAY-API-DEV-NAME: xxxxx X-EBAY-API-CERT-NAME: xxxxx BODY: v^1.1#i^1#r^0#p^3#I^3#f^ ... BwEQAA en_US High This is the first book in the Harry Potter series. In excellent condition! 377 1.0 true 4000 US USD 3 Days_7 Chinese PayPal 95125 1 ReturnsAccepted MoneyBack Days_30 If you are not satisfied, return the book for refund. Buyer Flat 1 USPSMedia 2.50 US I'm getting the following response from Ebay: RESPONSE: 200 OK 2016-11-15T05:15:56.825Z Failure Auth token is invalid. Validation of the authentication token in API request failed. 931 Error RequestError 971 E971_UNI_API5_18011427_R1 Anybody got an idea what I've been doing wrong? Any kind of help would be greatly appreciated! Thanks in advance!! Gerald
error-sandboxadditem apiauth-token
· 1
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.

Bump! There has be something going on with eBay or I'm just crazy. My application stopped working because of this. This article ( states the auth token can only contain certain characters: a to z, A to Z, 0 to 9 Asterisk, Slash, Plus ( * / +) Yet, the tokens returned have this garbage in the beginning: v^1.1#i^1#p^3#f^0#I^3#r^0#t^
0 Likes 0 ·

0 Answers

· Write an Answer

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.