【发布时间】:2014-11-09 20:54:12
【问题描述】:
我正在尝试让 Google OAuth 在 iOS 上运行,以便向 Google Calendar API 发出请求。我目前正在使用此代码将 Google 登录表加载到 UIWebView 并尝试取回访问令牌..
[AISWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/calendar&redirect_uri=%@&response_type=code&client_id=%@",kSharedURI,kClientId]]]];
通过使用 NSString 一次又一次地解析 HTML,我正在设法从出现在这里的文本字段中获取我认为的访问令牌。但是,当我尝试使用我认为是访问令牌的东西来使用 NSMutableURLRequest 发出这个日历请求时,我收到了来自 Google 的回复说
error = {
code = 401;
errors = (
{
domain = global;
location = Authorization;
locationType = header;
message = "Login Required";
reason = required;
}
);
message = "Login Required";
};
如果有人有任何想法,他们将不胜感激。谢谢。
【问题讨论】:
-
您是否对 kSharedURI 进行 url 编码?
标签: ios objective-c api oauth uiwebview