2012-03-22 5 views
6

"Google 이외의 서비스"에 대한 문서에 따라 OAuth 요청을 설정했으며이 중 90 %가 작동합니다. 응용 프로그램은 내가 내 응용 프로그램에 대한 올바른 액세스 토큰을 사용하여 인스 타 그램 및 범위 요청을 수락 로그인 할 수있는 웹보기를 제공하지만, 나는 다음과 같은 오류가 요청을 수락하면 :Instagram에 대해 gtm-oauth2를 사용하는 OAuth가 실패했습니다

Error Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. 
(com.google.HTTPStatus error 400.)" UserInfo=0x6b7ab00 {data=<7b22636f 6465223a 20343030 2c202265 72726f72 5f747970 65223a20 224f4175 74684578 63657074 696f6e22 2c202265 72726f72 5f6d6573 73616765 223a2022 596f7520 6d757374 20696e63 6c756465 20612076 616c6964 20636c69 656e745f 69642c20 20202020 20202020 20202020 72657370 6f6e7365 5f747970 652c2061 6e642072 65646972 6563745f 75726920 70617261 6d657465 7273227d>} 
Error data: 
{ 
    code = 400; 
    "error_message" = "You must include a valid client_id, response_type, and redirect_uri parameters"; 
    "error_type" = OAuthException; 
} 

이 컨트롤러처럼 보인다 이 (가) api.instagram.com 대신 google.com에 대한 OAuth 트랜잭션을 완료하려고 시도하고 있습니다.

static NSString *const kKeychainItemName = @"Instagram OAuth2"; 
static NSString *const kClientID = @"xxxxxxxxx"; // Removed for security 
static NSString *const kClientSecret = @"xxxxxxxxx"; // Removed for security 

static NSString *const authURLString = @"https://api.instagram.com/oauth/authorize/"; 
static NSString *const tokenURLString = @"https://api.instagram.com/oauth/authorize/"; 
static NSString *const redirectURI = @"http://google.com/NeverGonnaFindMe/"; 

... 

NSURL *tokenURL = [NSURL URLWithString:tokenURLString]; 

// Set up the OAuth request 
GTMOAuth2Authentication *auth = [GTMOAuth2Authentication 
      authenticationWithServiceProvider:@"Instagram API" 
      tokenURL:tokenURL 
      redirectURI:redirectURI 
      clientID:kClientID 
      clientSecret:kClientSecret 
     ]; 

// Specify the appropriate scope string, if any, according to the service's API documentation 
auth.scope = @"basic likes comments relationships"; 

NSURL *authURL = [NSURL URLWithString:authURLString]; 

// Display the authentication view 
GTMOAuth2ViewControllerTouch *viewController = [[GTMOAuth2ViewControllerTouch alloc] 
         initWithAuthentication:auth 
         authorizationURL:authURL 
         keychainItemName:kKeychainItemName 
         delegate:self 
         finishedSelector:@selector(viewController:finishedWithAuth:error:)              
        ]; 
// Capture the Cookie to delete later 
viewController.browserCookiesURL = [NSURL URLWithString:@"instagram.com/"]; 

// Now push our sign-in view 
[[self navigationController] pushViewController:viewController animated:YES]; 
+0

안녕하세요, plz plz plz 님과 함께이 사례를 공유 할 수 있습니까? – Hiren

+0

나는 내 블로그에 예제를 올렸다. [http://ifjoshrantheworld.com/instagram-oauth-login-for-ios-objective-c](http://ifjoshrantheworld.com/instagram-oauth-login-for-ios- objective-c) – JoshOiknine

+0

안녕하세요 조쉬 내가 성공적으로 로그인하고 accesstoken 얻을하지만 instagram에서 이미지를 공유하는 방법을 당신이 나를 도울 수 있는지 몰라? – Hiren

답변

3

그것은 정확 토큰 URL했다

https://groups.google.com/forum/?fromgroups#!topic/instagram-api-developers/SUYPX7ZQHhs

를 해결 :

여기에 설정하고 컨트롤러를 호출하는 내 목표 - C 코드입니다. 올바른 토큰 URL은 다음과 같습니다. https://api.instagram.com/oauth/access_token/

+0

그냥 똑같은 오류를 만들어 좋은 동안 내 머리를 긁었다; 다행 이구나! –

+0

도움이 되니 기쁩니다. – JoshOiknine

관련 문제