Google Reader Token 请求出现 403 错误
我正在尝试从 google reader 获取我的 iPhone 项目的令牌。我能够获得授权,但是当我请求令牌时,我收到 403 Forbidden
下面是我的代码实现。任何帮助将不胜感激。
//The tokenStorer contains the Authorization key
NSString *tokenStorer = [[NSUserDefaults standardUserDefaults]valueForKey:@"authKey"];
NSLog(@"%@", tokenStorer);
NSDictionary *cookieDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"www.google.com", @"Host",
@"iReader", @"User-Agent",
@"gzip, deflate", @"Accept-Encoding",
tokenStorer, @"Authorization",
nil
];
//@"Auth", NSHTTPCookieName, tokenStorer, NSHTTPCookieValue, @"./google.com", NSHTTPCookieDomain, @"/", NSHTTPCookiePath, nil];
//NSHTTPCookie *authCookie = [NSHTTPCookie cookieWithProperties:cookieDictionary];
//Google token url "http://www.google.com/reader/api/0/token?client=clientName"
NSURL *url=[[NSURL alloc] initWithString:GOOGLE_READER_TOKEN_URL];
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc]initWithURL:url];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setAllHTTPHeaderFields:cookieDictionary];
NSData *reciveData;
NSURLResponse *response;
NSError *error;
reciveData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
NSMutableURLRequest *tokenRequest= [[NSMutableURLRequest alloc] initWithURL:url];
NSString *trial = [[NSString alloc]initWithData:reciveData encoding:NSASCIIStringEncoding];
NSLog(@"%@ %d",trial, response);
[url release];
I am trying to get the token from google reader for my iPhone project. I am able to get the Authorization but when I request for the token, I get a 403 Forbidden
Below is my code implementation. Any help would be appreciated.
//The tokenStorer contains the Authorization key
NSString *tokenStorer = [[NSUserDefaults standardUserDefaults]valueForKey:@"authKey"];
NSLog(@"%@", tokenStorer);
NSDictionary *cookieDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"www.google.com", @"Host",
@"iReader", @"User-Agent",
@"gzip, deflate", @"Accept-Encoding",
tokenStorer, @"Authorization",
nil
];
//@"Auth", NSHTTPCookieName, tokenStorer, NSHTTPCookieValue, @"./google.com", NSHTTPCookieDomain, @"/", NSHTTPCookiePath, nil];
//NSHTTPCookie *authCookie = [NSHTTPCookie cookieWithProperties:cookieDictionary];
//Google token url "http://www.google.com/reader/api/0/token?client=clientName"
NSURL *url=[[NSURL alloc] initWithString:GOOGLE_READER_TOKEN_URL];
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc]initWithURL:url];
[urlRequest setHTTPMethod:@"GET"];
[urlRequest setAllHTTPHeaderFields:cookieDictionary];
NSData *reciveData;
NSURLResponse *response;
NSError *error;
reciveData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
NSMutableURLRequest *tokenRequest= [[NSMutableURLRequest alloc] initWithURL:url];
NSString *trial = [[NSString alloc]initWithData:reciveData encoding:NSASCIIStringEncoding];
NSLog(@"%@ %d",trial, response);
[url release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的代码解决了我的问题:
The below code solved my problem: