9

我正在使用我帐户的 Bearer 令牌(这是 Uber 应用程序的管理员)向https://sandbox-api.uber.com/v1/requests发出请求。

当我提出请求时,我得到一个 401:

{
    "message": "Missing scope: request",
    "code": "unauthorized"
}

正如我所说,我拥有的 access_token 是用于注册为应用程序管理员的电子邮件地址,所以这个请求应该可以正常工作吗?

4

3 回答 3

4

是的,当您致电https://login.uber.com/oauth/authorize

你应该请求“&scope=profile%20history_lite%20history%20request”

于 2015-04-16T09:55:57.630 回答
1

如果你在 Github 上尝试这个repo,它是 Uber API 的一个瘦包装器,你可以轻松地发出请求。

或者,如果你有 OAuth2 框架,你可以自己做范围的事情,你可以做的就是将必要的范围字符串传递到下面的 API:

[[NXOAuth2AccountStore sharedStore] setClientID:_clientID
                                         secret:_clientSecret
                                          scope:[NSSet setWithObjects:@"request", @"history_lite", @"profile", @"request_receipt", nil]
                               authorizationURL:[NSURL URLWithString:@"https://login.uber.com/oauth/authorize"]
                                       tokenURL:[NSURL URLWithString:@"https://login.uber.com/oauth/token"]
                                    redirectURL:[NSURL URLWithString:_redirectURL]
                                  keyChainGroup:nil
                                 forAccountType:_applicationName]; 
于 2015-07-15T03:34:04.267 回答
0

Uber OAuth 包含两个步骤:

  1. 授权端点:https ://login.uber.com/oauth/v2/authorize
  2. 令牌交换端点:https ://login.uber.com/oauth/v2/token

为了获得正确的范围,您需要将查询字符串传递给第一步 api 调用,例如:

https://login.uber.com/oauth/v2/authorize?client_id={cliend_id}&response_type=code&response_type=code&scope=profile%20history%20request%20places

然后您应该可以使用第 1 步https://your-redirect-uri/?code=AUTHORIZATION_CODE进一步交换 access_token。

access_token 本身应该告诉您是否获得了正确的范围,您可以通过https://jwt.io/进行检查,只需粘贴您的 access_token。

于 2016-11-25T05:57:48.367 回答