1

我只是编程的初学者。我正在尝试通过 OAuth2.0 和 GTM-OAuth2.0 登录谷歌帐户。构建可以成功,但我无法显示登录视图。我应该如何使用 pushViewControlle 方法?请给我一个建议。

我参考以下网站:http ://docs.kinvey.com/ios-oauth-guide.html

http://code.google.com/p/gtm-oauth2/wiki/Introduction

#import "GreaderMasterViewController.h"

#import "GreaderDetailViewController.h"

#import "GTMOAuth2ViewControllerTouch.h"

NSString *kKeychainItemName = @"Greader";


@interface GreaderMasterViewController () {
NSMutableArray *_objects;
}
@end

@implementation GreaderMasterViewController

- (GTMOAuth2Authentication * ) authForGoogle

{

NSString * url_string = @"http://www.google.com/reader/api";
NSURL * tokenURL = [NSURL URLWithString:url_string];

NSString * redirectURI = @"http://goes-nowhere-does-nothing";
GTMOAuth2Authentication * auth;
auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"reader"
                                                         tokenURL:tokenURL
                                                      redirectURI:redirectURI
                                                clientID:@"xxxxxxxx.apps.googleusercontent.com"
                                                     clientSecret:@"xxxxxxxxx"];


auth.scope = @"basic";

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];
}
4

0 回答 0