XeroAPI / xero-python-custom-connections-starter

Custom Connections starter app for xero-python and client_credentials grant
MIT License
2 stars 6 forks source link

Invalid client - referred by xero API support #2

Open bishwadeep opened 2 years ago

bishwadeep commented 2 years ago

Hi I have been trying to resolve the get token issue for too long now. I contact xero support and follow the instructions as they said. I followed each and every steps mentioned in the code document. I sent my console output to xero support, they asked me to regenerate the client secret, I changed it multiple times but still got invalid client error. Here is the last email from xero api support `Hi Bishwadeep

Our logs show the same error as before with the Client Secret being invalid. I would suggest raising this as an issue on the Github repo for the Python SDK and sample app.

It might also be useful to perform some debugging to ensure that the Client Secret is getting correctly used within your code.

Github: https://github.com/XeroAPI/xero-python-custom-connections-starter/issues

I would also suggest attempting the process in Postman: https://developer.xero.com/documentation/sdks-and-tools/tools/postman/#use-postman-with-custom-connections`

Here is the console log:

`127.0.0.1 - - [30/Nov/2021 21:53:06] "GET /get_token HTTP/1.1" 500 - 127.0.0.1 - - [30/Nov/2021 21:53:06] "GET /favicon.ico HTTP/1.1" 404 - 2021-11-30 21:53:07+1100 | DEBUG [urllib3.connectionpool.connectionpool.py:272] Resetting dropped connection: identity.xero.com 2021-11-30 21:53:07+1100 | DEBUG [urllib3.connectionpool.connectionpool.py:452] https://identity.xero.com:443 "POST /connect/token HTTP/1.1" 400 26 (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=UTF-8', 'Server': 'nginx', 'Xero-Origin-Id': 'IdentityServer.Web', 'Xero-Causation-Id': '3c9334b3c97443d09a7f263ba474073c', 'Xero-Message-Id': '577e3e59084e4b64a67d6684b0e4fd80', 'Xero-Activity-Id': 'dcd540b3cea544febd6c1edaaa460b0c', 'Xero-Correlation-Id': '587a22082b3e4ad8ae5a69837960cd58', 'Content-Length': '26', 'Expires': 'Tue, 30 Nov 2021 10:53:07 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Tue, 30 Nov 2021 10:53:07 GMT', 'Connection': 'close', 'Set-Cookie': 'Device=e4107c095c1a4cefba2c8ec204706b70; expires=Mon, 30 Nov 2026 10:53:07 GMT; path=/; samesite=none; httponly, bm_sz=86E17AA272B79CCFAB893D4101D75687YAAQXAUgF4pIl1F9AQAAzBB6cA1iIlKso76kTq2RO35XUriz8fin/kIIFG48b3wVmgRD+udO2jSP4eLyUz1ktgs8aaT8R/ij4js6g6PsfebDh/S1rWJfjL6jYTzcIybNUn1fZTpZ4B8VrBZWXMyZNOoo7pKURjef0rFBRsysuW6oyvNw06yahSk+Iemn3Q==; Domain=.xero.com; Path=/; Expires=Tue, 30 Nov 2021 14:53:07 GMT; Max-Age=14400; HttpOnly, _abck=2547C8FAB23428FC101103C29188DD01-1YAAQXAUgF4tIl1F9AQAAzBB6cAZzyrrxGERZDeYVfexLlnkho0K7e9mP2Qf1hPHkmOiNZ+qjwlQZP1ihKr4P2GLLk0+LUs1PaPoldzQ0wB3c78/2SOl4oDWFneVqAJT/ailGsFC84gjzSSwf4ASlhf1dBK+66CASH0cZmVXVugIT6siN1V1wL73vZc7gSzq0QmpkUYb4buZDOuWSVaGkGCIp/om8MXAVMPqegpUgGxFsXrgE6FZKJwOf3iiuZ8rTgKYPYVfsO3BJpRS+77gCoWJcCYXAKPdzhmlH8HcW+foGdOWtGTUYeRJHW7YnkdcT5gf3PTD84LeZkKX+w23I5/sZlcBbUbimbmtVuoIBwp/jm2v+US/5-1~-1~-1; Domain=.xero.com; Path=/; Expires=Wed, 30 Nov 2022 10:53:07 GMT; Max-Age=31536000; Secure'}) HTTP response body: b'{"error":"invalid_client"}'

[2021-11-30 21:53:07,530] ERROR in app: Exception on /get_token [GET] Traceback (most recent call last): File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/Users/bd/Sites/xero-python-custom-connections-starter/app.py", line 113, in get_token xero_token = api_client.get_client_credentials_token() File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/api_client/init.py", line 767, in get_client_credentials_token if oauth2_token.get_client_credentials_access_token(self, app_store_billing): File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/api_client/oauth2.py", line 243, in get_client_credentials_access_token new_token = token_api.get_client_credentials_token(app_store_billing) File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/api_client/oauth2.py", line 96, in get_client_credentials_token response, status, headers = self.api_client.call_api( File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/api_client/init.py", line 350, in call_api return self.__call_api( File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/api_client/init.py", line 196, in __call_api response_data = self.request( File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/api_client/init.py", line 429, in request return self.rest_client.POST( File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/rest.py", line 331, in POST return self.request( File "/Users/bd/Sites/xero-python-custom-connections-starter/venv/lib/python3.9/site-packages/xero_python/rest.py", line 240, in request raise HTTPStatusException(http_resp=RESTResponse(r)) xero_python.exceptions.http_status_exceptions.HTTPStatusException: (400) Reason: Bad Request HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=UTF-8', 'Server': 'nginx', 'Xero-Origin-Id': 'IdentityServer.Web', 'Xero-Causation-Id': '3c9334b3c97443d09a7f263ba474073c', 'Xero-Message-Id': '577e3e59084e4b64a67d6684b0e4fd80', 'Xero-Activity-Id': 'dcd540b3cea544febd6c1edaaa460b0c', 'Xero-Correlation-Id': '587a22082b3e4ad8ae5a69837960cd58', 'Content-Length': '26', 'Expires': 'Tue, 30 Nov 2021 10:53:07 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Tue, 30 Nov 2021 10:53:07 GMT', 'Connection': 'close', 'Set-Cookie': 'Device=e4107c095c1a4cefba2c8ec204706b70; expires=Mon, 30 Nov 2026 10:53:07 GMT; path=/; samesite=none; httponly, bm_sz=86E17AA272B79CCFAB893D4101D75687YAAQXAUgF4pIl1F9AQAAzBB6cA1iIlKso76kTq2RO35XUriz8fin/kIIFG48b3wVmgRD+udO2jSP4eLyUz1ktgs8aaT8R/ij4js6g6PsfebDh/S1rWJfjL6jYTzcIybNUn1fZTpZ4B8VrBZWXMyZNOoo7pKURjef0rFBRsysuW6oyvNw06yahSk+Iemn3Q==; Domain=.xero.com; Path=/; Expires=Tue, 30 Nov 2021 14:53:07 GMT; Max-Age=14400; HttpOnly, _abck=2547C8FAB23428FC101103C29188DD01-1YAAQXAUgF4tIl1F9AQAAzBB6cAZzyrrxGERZDeYVfexLlnkho0K7e9mP2Qf1hPHkmOiNZ+qjwlQZP1ihKr4P2GLLk0+LUs1PaPoldzQ0wB3c78/2SOl4oDWFneVqAJT/ailGsFC84gjzSSwf4ASlhf1dBK+66CASH0cZmVXVugIT6siN1V1wL73vZc7gSzq0QmpkUYb4buZDOuWSVaGkGCIp/om8MXAVMPqegpUgGxFsXrgE6FZKJwOf3iiuZ8rTgKYPYVfsO3BJpRS+77gCoWJcCYXAKPdzhmlH8HcW+foGdOWtGTUYeRJHW7YnkdcT5gf3PTD84LeZkKX+w23I5/sZlcBbUbimbmtVuoIBwp/jm2v+US/5-1~-1~-1; Domain=.xero.com; Path=/; Expires=Wed, 30 Nov 2022 10:53:07 GMT; Max-Age=31536000; Secure'}) HTTP response body: b'{"error":"invalid_client"}'

127.0.0.1 - - [30/Nov/2021 21:53:07] "GET /get_token HTTP/1.1" 500 - 127.0.0.1 - - [30/Nov/2021 21:53:07] "GET /favicon.ico HTTP/1.1" 404 -`

I have even sent the video to the api support and they confirmed I did it correctly.