我已在我的应用程序中集成了身份验证链接。 它工作正常,但今天它没有在我的应用程序的Web视图中加载页面。 我收到如下响应令牌的响应: API响应:::: ****************
<NSHTTPURLResponse: 0x1468fa30> { URL: https://api.linkedin.com/uas/oauth/requestToken } { status code: 400, headers {
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8";
Date = "Tue, 25 Nov 2014 07:11:16 GMT";
Server = "Apache-Coyote/1.1";
"Set-Cookie" = "lidc=\"b=LB83:g=130:u=1:i=1416899476:t=1416985876:s=2341738268\"; Expires=Wed, 26 Nov 2014 07:11:16 GMT; domain=.linkedin.com; Path=/";
"Transfer-Encoding" = Identity;
Vary = "Accept-Encoding";
"Www-Authenticate" = "OAuth realm=\"https%3A%2F%2Fapi.linkedin.com\", oauth_problem=\"timestamp_refused\", oauth_acceptable_timestamps=\"1416899476%2B-900\"";
"X-FS-UUID" = 4ff0ed1a91d6a913f0761484b22a0000;
"X-LI-UUID" = "T/DtGpHWqRPwdhSEsioAAA==";
"X-Li-Fabric" = "PROD-ELA4";
"X-Li-Pop" = "prod-nsg7";
}}
请尽快回复。
来自链接的用户个人资料的代码:
self.consumer = [[OAConsumer alloc] initWithKey:LINKEDIN_APIKEY
secret:LINKEDIN_SECRETKEY
realm:@"http://api.linkedin.com/"];
requestTokenURL = [NSURL URLWithString:@"https://api.linkedin.com/uas/oauth/requestToken"]
linkedInCallbackURL = LINKEDIN_LINKEDINCALLBACKURL;
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:requestTokenURL
consumer:self.consumer
token:nil
callback:linkedInCallbackURL
signatureProvider:nil];
[request setHTTPMethod:@"POST"];
OARequestParameter *nameParam = [[OARequestParameter alloc] initWithName:@"scope"
value:@"r_basicprofile+r_emailaddress"];
NSArray *params = [NSArray arrayWithObjects:nameParam, nil];
[request setParameters:params];
OARequestParameter * scopeParameter=[OARequestParameter requestParameter:@"scope" value:@"r_fullprofile r_emailaddress"];
[request setParameters:[NSArray arrayWithObject:scopeParameter]];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(requestTokenResult:didFinish:)
didFailSelector:@selector(requestTokenResult:didFail:)];
加载链接的网页查看方法:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
BOOL requestForCallbackURL = ([urlString rangeOfString:linkedInCallbackURL].location != NSNotFound);
if ( requestForCallbackURL )
{
BOOL userAllowedAccess = ([urlString rangeOfString:@"user_refused"].location == NSNotFound);
if ( userAllowedAccess )
{
[self.requestToken setVerifierWithUrl:url];
[self accessTokenFromProvider];
}
else
{
// User refused to allow our app access
// Notify parent and close this view
UIAlertView *alrt=[[UIAlertView alloc] initWithTitle:@"Linked In" message:@"App access denied by the user." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alrt show];
[webView removeFromSuperview];
}
}
return YES;
}