【问题标题】:how to oatuh authentication on vimeo如何在 vimeo 上进行 oauth 身份验证
【发布时间】:2013-10-16 19:38:37
【问题描述】:

我正在使用 gtm oauth 框架对 vimeo 进行 oatuh 身份验证。我的问题是,当我使用 gtmo 框架成功获取访问令牌时,我调用下面的函数来获取 vimeo 的视频 json 值,但我收到此错误:

{"generated_in":"0.0046","stat":"fail","err":{"code":"401","expl":"传递的 oauth_signature 无效。","msg" :"无效签名"}}

实际上,问题是当我从 auth 对象获取签名值时,auth 对象中不存在签名参数。请指导我在哪里做错了:

- (void) fetchNetwork:(GTMOAuthAuthentication *)auth
{
    NSLog(@"auth access token %@",auth.accessToken);
      NSLog(@"auth access token %@",auth.token);
    NSLog(@"auth consumer key %@",auth.consumerKey);
    NSLog(@"auth  token%@",auth.token);
    NSLog(@"realm %@",auth.realm);
    NSLog(@"auth  version %@",auth.version);
    NSLog(@"auth  signature method %@",auth.signatureMethod);
    NSLog(@"auth  time stamp%@",auth.timestamp);
    NSLog(@"auth  nonce %@",auth.nonce);


    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://vimeo.com/api/rest/v2?format=json&method=vimeo.videos.search&oauth_consumer_key=%@&oauth_nonce=%@&oauth_signature_method=%@&oauth_timestamp=%@&oauth_version=%@&oauth_signature=%@&query=amirkhan",auth.consumerKey,auth.nonce,auth.signatureMethod,auth.timestamp,auth.version,@""]];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

                   [request setHTTPMethod:@"GET"];

     NSLog(@"response string:%@",request);
    NSHTTPURLResponse* urlResponse = nil;

    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:nil];
     NSLog(@"response string:%@",responseData);
    NSString *strResponse = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"response string:%@",strResponse);
    NSLog(@"Response Code: %d", [urlResponse statusCode]);

    }

【问题讨论】:

  • 嗨,你找到答案了吗?我也有同样的问题。请帮忙。

标签: iphone objective-c oauth


【解决方案1】:

您好,我可能来不及回复了。 但是您需要将经过身份验证的签名与这样的每个请求一起附加

[signedAuth authorizeRequest:request];

其中 signedAuth 是 GTMOAuthAuthentication 在认证后返回的实例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-09
    • 1970-01-01
    • 2017-06-08
    • 2015-12-08
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    相关资源
    最近更新 更多