Google API 콘솔 용 애플리케이션을 등록합니다. 그리고 내 클라이언트 비밀 번호, 클라이언트 ID 및 두 개의 리디렉션 uris.내가 사용해야하는 URI 리디렉션 (OAuth 2.0)?
//● urn:xxxxxxx:oob
//● http://localhostxxxxxx
물론이 항목을 사용하여 Google에 토큰을 요청하는 데 성공했습니다. 그러나 승인 버튼 (예 : "이 애플리케이션을 승인 하시겠습니까?")을 클릭하면 두 개의 응답이 발생합니다.
urnxxxxxx를 사용하는 경우 '작업을 완료 할 수 없습니다 (com.google.HTTPStatus error 404.)'메시지가 표시됩니다.
//Or If I use http://localhostxxxxxxxxxxxxx and click Yes button, then nothing
happens.
어떻게해야합니까? 다음 코드는 google reader 용입니다.
#import "MasterViewController.h"
#import "DetailViewController.h"
#import "GTMOAuth2Authentication.h"
#import "GTMOAuth2ViewControllerTouch.h"
#import "GTMOAuth2WindowController.h"
static NSString *const kKeychainItemName = @"Greader";
@interface MasterViewController() {
NSMutableArray *_objects;
}
@end
@implementation MasterViewController
- (IBAction)authentication:signInToGoogle:(id)sender;
{}
- (GTMOAuth2Authentication *) authForGoogle
{
NSString * url_string = @"http://www.google.com/reader/api/";
NSURL * tokenURL = [NSURL URLWithString:url_string];
NSString * redirectURI = @"xxxxoob";
GTMOAuth2Authentication * auth;
auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"reader"
tokenURL:tokenURL
redirectURI:redirectURI
clientID:@"xxxxx"
clientSecret:@"xxxx"];
auth.scope = @"http://www.google.com/reader/api/";
return auth;
}
- (void)signInToGoogle
{
GTMOAuth2Authentication * auth = [self authForGoogle];
NSString* auth_string = @"https://accounts.google.com/o/oauth2/auth";
NSURL * authURL = [NSURL URLWithString:auth_string];
GTMOAuth2ViewControllerTouch * viewController;
viewController = [[GTMOAuth2ViewControllerTouch alloc]initWithAuthentication:auth
authorizationURL:authURL
keychainItemName:kKeychainItemName
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[self.navigationController pushViewController:viewController animated:YES];
}
감사합니다. 나는 OAuth를 배우고 있으며 아직 초보자입니다. 하지만 .... 나는 이미 OAuth에 대해 조금 배웠고, 하나의 큰 질문이 있습니다. 편리 할 때 제 질문에 대답 해 주시겠습니까? – user1702650
내 앱이 인증 페이지로 리디렉션 된 것을 알았을 때 사용자가 내 앱을 승인 한 후에 사용할 "클라이언트 비밀번호" "범위"및 "리디렉션 uri"를 게시해야합니다. 그리고 리디렉션 uri로 @ "xxxxoob"을 선택했습니다. 당신은 인증 흐름이 작동 할 때 이것이 필요하다고 생각합니다.)하지만 여전히 "com.google.HTTPStatus error 404"오류가 있습니다. 잘못된 uri를 사용하는 것을 제외하고는 가능합니까? – user1702650
404를 얻으면 나는 문제는 인증 페이지의 URL입니다. 다시 확인하여 문제가 없는지 확인하십시오.이 문제에 대한 새로운 스레드를 열어 추가 정보 (예 : URL 등)를 붙여 넣을 수 있습니다. BTW if 내 첫 번째 대답이 도움이되었고, 친절하게도 친절하고 올바른 것으로 표시 ("0"바로 아래) :-) – OhadR