Objective c ASIHTTPRequest需要身份验证时出错

Objective c ASIHTTPRequest需要身份验证时出错,objective-c,ios,youtube-api,asihttprequest,gdata-api,Objective C,Ios,Youtube Api,Asihttprequest,Gdata Api,我在谷歌上搜索过很多次,但我找不到任何可以理解的AsiTpRequest和Youtube API教程。我在Stackoverflow和其他论坛上也问了很多问题,但没人能帮上忙。 我试着从youtube上获取最喜欢的视频列表。我已成功登录并获得accesstoken。我将其设置为带有密钥授权的请求标头,但Youtube始终返回错误: 响应失败,消息为:错误域=ASIHTTPRequestErrorDomain 代码=3“需要身份验证”用户信息=0x933b980 {NSLocalizedDescr

我在谷歌上搜索过很多次,但我找不到任何可以理解的AsiTpRequest和Youtube API教程。我在Stackoverflow和其他论坛上也问了很多问题,但没人能帮上忙。 我试着从youtube上获取最喜欢的视频列表。我已成功登录并获得accesstoken。我将其设置为带有密钥授权的请求标头,但Youtube始终返回错误:

响应失败,消息为:错误域=ASIHTTPRequestErrorDomain 代码=3“需要身份验证”用户信息=0x933b980 {NSLocalizedDescription=需要身份验证}

这是我的密码:

#define CONNECTION_GET_FAVORITE_LIST @"https://gdata.youtube.com/feeds/api/users/default/favorites"

- (void) getFavoriteList{


  NSURL *url = [NSURL URLWithString:CONNECTION_GET_FAVORITE_LIST];
    ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
    [request addRequestHeader:@"Authorization" value:[@" Bearer "  stringByAppendingString:<accesstoken goes here>];
    request 
    [request startAsynchronous];
    [request setCompletionBlock:^{
        NSString* respondMessage = [request responseString];
        NSLog(@"Respond complete with message: %@",respondMessage);
    }];
    [request setFailedBlock:^{
        NSString* respondMessage = [request error];
        NSLog(@"Respond failed with message: %@",respondMessage);
    }];
    [request release];
}
#定义连接(获取)收藏(列表)https://gdata.youtube.com/feeds/api/users/default/favorites"
-(void)getFavoriteList{
NSURL*url=[NSURL URLWithString:CONNECTION\u GET\u FAVORITE\u LIST];
ASIHTTPRequest*请求=[[ASIHTTPRequest alloc]initWithURL:url];
AppDelegate*AppDelegate=(AppDelegate*)[[UIApplication sharedApplication]委托];
[request addRequestHeader:@“Authorization”值:[@“Bearer”stringByAppendingString:];
要求
[请求启动同步];
[请求setCompletionBlock:^{
NSString*respondMessage=[request responseString];
NSLog(@“响应完成,消息:%@”,respondMessage);
}];
[请求设置失败块:^{
NSString*respondMessage=[请求错误];
NSLog(@“响应失败,消息:%@”,respondMessage);
}];
[请求释放];
}
更新:当我尝试使用方法GET并将链接上的accesstoken设置为:
https://gdata.youtube.com/feeds/api/users/default/favorites?v=2&access_token=
,youtube抛出错误:

令牌无效-AuthSub令牌的作用域错误

错误401

请帮我解决这个问题。
非常感谢

首先不要使用
ASIHTTPRequest
使用
AFNetworking
。但是这里你不需要任何人

现在,您的请求需要
身份验证和授权
gdata
才能请求在
youtube
中获取
feed

编辑:参考链接


参考链接。

您是否尝试过使用中提到的curl从命令行测试相同的请求,以检查令牌是否有效?