finishedWithAuth 方法 not called after authenticate method

I have go step by step what Google+ Sign-In for iOS said.but't this method cant' be called.

下面是我的代码:

viewController.h

#import <UIKit/UIKit.h>
#import <GoogleOpenSource/GoogleOpenSource.h>
#import <GooglePlus/GooglePlus.h>
#import <QuartzCore/QuartzCore.h>

@class GPPSignInButton;
@interface ViewController : UIViewController<GPPSignInDelegate>

@property (retain, nonatomic) IBOutlet GPPSignInButton *signInButton;

@end

ViewController.m


#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
static NSString * const kClientID = @"602865423207-1v9cenqp7e78lsgv5e3t3k05o877mjap.apps.googleusercontent.com";

@synthesize signInButton;
  • (void)viewDidLoad {

        [super viewDidLoad];
        GPPSignIn *signIn = [GPPSignIn sharedInstance];
        signIn.clientID = kClientID;
        signIn.scopes = [NSArray arrayWithObjects:
                    kGTLAuthScopePlusLogin, // defined in GTLPlusConstants.h
                    nil];
        signIn.delegate = self;
    }
    
    • (void)finishedWithAuth: (GTMOAuth2Authentication *)auth

                   error: (NSError *) error

      {

         NSLog(@"Received error %@ and auth object %@",error, auth);

      }

    • (BOOL)application: (UIApplication )application openURL: (NSURL )url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation
      {

         return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];

      }

    @end
    

各位帮忙看看到底什么问题,代理也设了,SDK是通过CocosPod安装的,应该也没有问题,参考了人家官方的例子,我觉得,能用的,我都用上了,为什么就是无法回调啊-,-

去stackoverflow上查了查,同样的问题不少,可是回答都没有解决我的问题

阅读 3.8k
1 个回答

Success! You've authorized SegmentFaultLogin. Please return to your device to continue.
我用你的client id登陆成功了。
你贴的代码看不出问题,但是问题应该出在你的代码上。
对照文档看看吧。
https://developers.google.com/+/mobile/ios/sign-in

curl -d "client_id=602865423207-1v9cenqp7e78lsgv5e3t3k05o877mjap.apps.googleusercontent.com&scope=email profile" https://accounts.google.com/o/oauth2/device/code
用返回值中的device_code替换下面的code,把client_secret换成你自己的
curl -d  "client_id=602865423207-1v9cenqp7e78lsgv5e3t3k05o877mjap.apps.googleusercontent.com&client_secret={clientSecret}&code={code}&grant_type=http://oauth.net/grant_type/device/1.0" https://accounts.google.com/o/oauth2/token

这样试试,如果取到了token ,那就说明是你代码的问题了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏