0
我正在關注this link以獲取訪問令牌,但有些漏洞在下面的代碼中,特別是在網址和內容中。ios - 如何獲取訪問令牌?
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if(_data)
{
NSString* content = [[NSString alloc] initWithData:_data
encoding:NSUTF8StringEncoding];
[_data release];
_data = nil;
NSString *jsString = @"<script type='text/javascript'>\
window.external =\
{\
'Notify': function(s) { document.location = 'acs://settoken?token=' + s; },\
'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\
}\
</script>";
//Here appending the above javascript with content
content = [jsString stringByAppendingString:content];
NSURL *url = [[NSURL alloc] initWithString:@"https://converse.accesscontrol"];
[webView loadHTMLString:content baseURL:url];
}
}
當登錄到Gmail或Yahoo,下面的代碼將被解僱,然後檢查URL,但在這裏(如果條件不滿足)。如果你能不能夠明白,我想要問。請參閱上面給出的鏈接。
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType
{
_url = [[NSURL alloc] initWithString:@"https://converse.accesscontrol.windows"];
if(_url)
{
if([_url isEqual:[request URL]])
{
return YES;
}
[_url release];
}
_url = [[request URL] retain];
NSString* scheme = [_url scheme];
if([scheme isEqualToString:@"acs"])
{
// parse the JSON URL parameter into a dictionary
NSDictionary* pairs = [self parsePairs:[_url absoluteString]];
if(pairs)
{
WACloudAccessToken* accessToken;
accessToken = [[WACloudAccessToken alloc] initWithDictionary:pairs];
[WACloudAccessControlClient setToken:accessToken];
[self dismissModalViewControllerAnimated:YES];
}
return NO;
}
[NSURLConnection connectionWithRequest:request delegate:self];
return NO;
}
任何想法?提前致謝。
感謝您的回覆,我們爲什麼需要這個設備我要去的路嗎? – 2013-05-02 07:27:25
你得到並享受 – hitesh 2013-05-02 07:32:46
你的代碼加載在Safari中的內容,它是如此複雜的獲取令牌,我試圖加載在UIWebview – 2013-05-02 07:35:40