获取uber身份验证令牌时获取错误

时间:2016-02-22 19:01:59

标签: authentication oauth uber-api

从优步获取身份验证令牌是一个两步过程。 请参阅Uber Auth API

  1. 要求超级用户授权:致电GET https://login.uber.com/oauth/v2/authorize?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}
  2. 提供您的client_id和redirect_uri特定于您的网站。如果授权成功,您将使用查询参数中的代码重定向到您的站点。

    1. 您在步骤1中获取的代码,用于检索身份验证令牌。 向https://login.uber.com/oauth/v2/token发送HTTP POST请求。以下应该是您发送给服务器的json:

      {       “client_secret”:“{client_secret}”,       “client_id”:“{client_id}”,       “grant_type”:“{authorization_code}”,       “redirect_uri”:“{redirect_uri}”,       “code”:“{插入上一步获得的授权码}” }

    2. 在第二步中,我总是收到错误400,其中包含“无效授权类型”消息。请告诉我哪里出错了。

2 个答案:

答案 0 :(得分:2)

您需要将参数作为表单数据发送,而不是JSON。请查看第3部分中的卷曲示例:https://developer.uber.com/docs/authentication

答案 1 :(得分:1)

authorization and authentication documentation并未提及有关JSON的任何内容,因此application/x-www-form-urlencoded media type将用于将HTTP POST请求发送到/oauth/v2/token API端点

相关问题