Uber API endpoints not working with real server domain but working well with sandbox

守給你的承諾、 提交于 2019-12-01 12:19:16

问题


I have been testing Uber API for a month and I have seen some unstable behaviors recently.

In my code there are some unusual response returned from Uber endpoints. Now I am pasting the screen shots of my code here below:

You can see I have a global string type variable "baseURL", I keep switching it between real server and sandbox as below: "https://api.uber.com/v1" and "https://sandbox-api.uber.com/v1"

But from my testing result, I can tell that most the API in sandbox work perfectly well but when I switched to the real server domain, all of the ones that I have tested did not work at all.

Update: For the sandbox environment, /v1/estimates/time does not work either. It would return 401. My request url is like this: https://sandbox-api.uber.com/v1/estimates/time?server_token=myToken&start_latitude=39.914097&start_longitude=116.458539.

1) POST /v1/request/estimate

I am sure "POST" is what the Uber API doc suggests (https://developer.uber.com/v1/endpoints/). But this screen shot was taken when I switched to the real server (sandbox works no problem with the same code).

It returned: "Method not supported for this endpoint." / "method_not_allowed" with 405 code.

2) POST /v1/requests

Same behavior with the real server (sandbox works good) like below, and it also returned "invalid OAuth 2.0 credentials provided." / "unauthorized" with 405 code. But I'm sure I can use the same credentials to make requests in sandbox.

3) GET /v1/estimates/time

Even this API, it doesn't require access token but still returned "No authentication provided." / "unauthorized" with 401 code. Please note that it works well for the sandbox but fails for the real server.

Please help, many thanks!


回答1:


Everyone can use the Uber API Request endpoint in the sandbox environment, but using it in production requires whitelisting. You can request your app to be whitelisted on the Uber support page: https://developer.uber.com/support/.

For the /v1/estimates/time endpoint, a server token or an access token is required in production, but no whitelisting is required for this.



来源:https://stackoverflow.com/questions/32048746/uber-api-endpoints-not-working-with-real-server-domain-but-working-well-with-san

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!