【发布时间】: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