如何推送视图控制器才能登录Google?

时间:2012-10-14 11:55:30

标签: objective-c oauth

我只是编程的初学者。我正在尝试通过OAuth2.0和GTM-OAuth2.0登录Google帐户。构建可以成功,但我无法显示登录视图。我该如何使用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];
}

0 个答案:

没有答案