2012-03-22 7 views
6

के लिए gtm-oauth2 का उपयोग करने में विफल OAuth मैंने "गैर-Google सेवा" के लिए दस्तावेज़ के बाद OAuth अनुरोध स्थापित किया है और मुझे इस काम का 9 0% मिलता है। एप्लिकेशन किसी वेब दृश्य, जहां मैं अपने अनुप्रयोग के लिए सही पहुँच टोकन का उपयोग कर Instagram और गुंजाइश अनुरोध स्वीकार करने के लिए लॉग इन कर सकते हैं लाता है, लेकिन एक बार मैं अनुरोध मैं निम्नलिखित त्रुटि मिलती है स्वीकार करते हैं:Instagram

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- उद्देश्य-सी) – JoshOiknine

+0

हाय जोश मैंने सफलतापूर्वक लॉगिन किया है और accesstoken भी प्राप्त किया है, लेकिन यह नहीं पता कि Instagram में छवि को साझा करने के लिए आप मेरी मदद कर सकते हैं? – Hiren

उत्तर

3

हल

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

यह टोकन URL कि गलत थी:

यहाँ की स्थापना की और नियंत्रक आह्वान करने के लिए मेरी उद्देश्य-सी कोड है। सही टोकन यूआरएल है: https://api.instagram.com/oauth/access_token/

+0

को पोस्ट करने के तरीके के बारे में जानें, बस एक ही त्रुटि के लिए सटीक एक ही त्रुटि और खरोंच किया; खुशी है मैंने यह पाया! –

+0

खुशी हुई यह मदद की। – JoshOiknine