首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >uber api乘车请求得到401个非自动化错误响应

uber api乘车请求得到401个非自动化错误响应
EN

Stack Overflow用户
提问于 2016-11-07 11:28:42
回答 1查看 217关注 0票数 0

我正在尝试为UBER.I构建mac应用程序,我已经完成了Aouth2的所有步骤。我成功地获得了access_token。我也可以检索用户的个人资料和历史,但当我试图发布“乘坐请求”,我得到401个未经授权的错误response.please help.Thank你提前。我的代码如下。

**

代码语言:javascript
复制
//POST /v1/requests
    NSString *sandBoxURL=@"https://sandbox-api.uber.com/v1";
    NSString *url = [NSString stringWithFormat:@"%@/requests", sandBoxURL];

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
    [request addValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [request addValue:[NSString stringWithFormat:@"Bearer %@", _accessToken] forHTTPHeaderField:@"Authorization"];

    NSError *error = nil;
    request.HTTPMethod = @"POST";
    request.HTTPBody = [NSJSONSerialization dataWithJSONObject:params options:0 error:&error];
    NSLog(@"Request for Product Request:%@",request);
    [self performNetworkOperationWithRequest:request completionHandler:^(NSDictionary *requestDictionary, NSURLResponse *response, NSError *error)
     {
         NSLog(@"Response for Product Request:%@",response);
         NSLog(@"Result:%@",requestDictionary);
         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
         if (httpResponse.statusCode >= 200 && httpResponse.statusCode < 300)
         { //OK
             UberRequest *requestResult = [[UberRequest alloc] initWithDictionary:requestDictionary];
             // handler(requestResult, response, error);
         }
         if (409 == httpResponse.statusCode) { //needs surge confirmation
             NSLog(@"Surge Conflict");
         }
         else
         {
            NSLog(@"Error In response");

         }
     }];

**我得到的回应是:

代码语言:javascript
复制
    { URL: https://sandbox-api.uber.com/v1/requests } { status code: 401, headers {
    Connection = "keep-alive";
    "Content-Length" = 83;
    "Content-Type" = "application/json";
    Date = "Mon, 07 Nov 2016 11:19:35 GMT";
    Server = nginx;
    "Strict-Transport-Security" = "max-age=0";
    "X-Content-Type-Options" = nosniff;
    "X-Uber-App" = "uberex-sandbox, migrator-uberex-sandbox-optimus";
    "X-Uber-Missing-Scopes" = true;
    "X-XSS-Protection" = "1; mode=block";
} }
Result:{
    code = unauthorized;
    message = "Requires at least one scope. Available scopes: ";
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-03 06:22:54

我找到解决办法了。问题是我的作用域input.While请求令牌,即使您登录的帐户是开发人员的,我们也需要正确地放置作用域。在我的例子中,我需要请求范围来标记。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40464095

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档