Scenario: Login to App via Google+ Login
Implementation:
- (void)viewDidLoad {
[super viewDidLoad];
GPPSignIn *aGPSSignIn = [GPPSignIn sharedInstance];
aGPSSignIn.scopes = @[ kGTLAuthScopePlusLogin, kGTLAuthScopePlusUserinfoEmail, kGTLAuthScopePlusUserinfoProfile, kGTLAuthScopePlusMe];
aGPSSignIn.shouldFetchGoogleUserEmail = YES;
aGPSSignIn.shouldFetchGooglePlusUser =YES;
aGPSSignIn.homeServerClientID = kClientID;
aGPSSignIn.clientID = kClientID;
aGPSSignIn.delegate = self;
if (![aGPSSignIn trySilentAuthentication]) {
[self showLoginButton];
}
}
- (void)showLoginButton {
if (!self.signInButton) {
self.signInButton = [GPPSignInButton buttonWithType:UIButtonTypeCustom];
[self.signInButton setFrame:CGRectMake(60, 100, 200, 40)];
}
[self.view addSubview:self.signInButton];
}
#pragma mark - GPPSignInDelegate
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error {
NSString *anAccessToken = auth.accessToken;
NSLog(@"googleAccessToken:%@",anAccessToken);
}
- (void)didDisconnectWithError:(NSError *)iError {
if (iError) {
NSLog(@"Error:%@", iError);
}
}
Note: - (BOOL)application: (UIApplication *)application openURL: (NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation: (id)annotation
is handled in the AppDelegate.
Issue:
Error:
Received error Error Domain=com.google.GooglePlusPlatform Code=-1 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x15d95f90 {NSLocalizedDescription=The operation couldn’t be completed. (com.google.HTTPStatus error 400.)} and auth object (null)
It will be very helpful if someone can guide me in solving this issue. Thanks.
In your browser, type: plus.google.com and sign up with your Google account. If you haven't created a Google account, you will be redirected to the sign up flow.
Google+ (pronounced Google plus) is a Google social networking platform. The Google+ design team sought to replicate the way people interact offline more closely than is the case in other social networking services, such as Facebook and Twitter. The project's slogan is “Real-life sharing rethought for the web.”
Google Plus, the company's failed social network, is officially gone as of today. After Google Plus personal accounts were shut down last year, Google announced that it would be replacing the social network for enterprise users with Google Currents.
In your browser, type: plus.google.com and sign up with your Google account. If you haven't created a Google account, you will be redirected to the sign up flow.
When you sign in to your Google Account, you can see and manage your info, activity, security options, and privacy preferences to make Google work better for you. You can review and adjust some privacy options now, and find even more controls if you sign in or create an account. Learn more. Sign in.
Your Google Account automatically protects your personal information and keeps it private and safe. Every account comes with powerful features like spam filters that block 99.9% of dangerous emails before they ever reach you, and personalized security notifications that alert you of suspicious activity and malicious websites.
On some apps and devices, you can use an app password to sign in to your Google Account.
Please set the URL scheme in project.
steps:
If it is not working try by replacing the 'REDIRECT URIS' with 'BUNDLE ID', i.e., the Identifier and URL Schemes are same.
Hope this may help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With