首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用gtm-oauth2 for Instagram时OAuth失败

使用gtm-oauth2 for Instagram时OAuth失败
EN

Stack Overflow用户
提问于 2012-03-22 11:55:55
回答 1查看 6K关注 0票数 6

我已经按照“非谷歌服务”的文档设置了OAuth请求,并且我得到了90%的工作。该应用程序会显示一个web视图,我可以在其中使用应用程序的正确访问令牌登录Instagram,并接受作用域请求,但一旦我接受该请求,我就会收到以下错误:

代码语言:javascript
复制
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;
}

控制器似乎正在尝试完成针对google.com而不是api.instagram.com的OAuth事务。

下面是我用来设置和调用控制器的objective-c代码:

代码语言:javascript
复制
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];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-23 06:54:52

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9816226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档