I'm trying to add the GooglePlus API into my app.
I've added the Google+ framework using CocoaPods and I've got the sign in button in my app.
The GPPSignIn
object is set up as follows in the viewDidLoad
function in the view controller that does the signing in...
@property (nonatomic, strong) GPPSignIn *signIn;
...
self.signIn = [GPPSignIn sharedInstance];
self.signIn.clientID = @"blahblahmynumber.apps.googleusercontent.com";
self.signIn.scopes = @[kGTLAuthScopePlusLogin];
self.signIn.delegate = self;
[self.signIn trySilentAuthentication];
Then when the sign in button is pressed...
- (IBAction)googleButtonPressed:(id)sender
{
[self.signIn authenticate];
}
... and the delegate method...
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error
{
NSLog(@"Received error %@ and auth object %@",error, auth);
}
It all seems to work, I get pushed off to Google to sign in and confirm access to my account and then I get pushed back to the app and the console shows...
Received error Error Domain=com.google.GooglePlusPlatform Code=-1 "Mismatched authentication" UserInfo=0x1d5cb170 {NSLocalizedDescription=Mismatched authentication} and auth object (null)
Now I'm stuck. I can't find any information on what "Mismatched Authentication" means?
BTW, all the code I've written has come from the Google developer portal and "How to" docs.
Things I have attempted so far
kGTLAuthScopePlusLogin
and kGTLAuthScopePlusMe
.redirect_uri_mismatch
problem. The problem is "Mismatched Authentication" returned to the sign in delegate after signing in.OK, fix for this was easy. Delete some code.
I followed the Google Docs on how to create a sign in screen to the letter.
I added the GPPSignInButton
and attached it to a function to run [signIn authenticate]
.
However, this is where I went wrong. The GPPSignInButton
has this function built in. Somehow, by making it run exactly the same function it was causing this error to appear.
The fix was simple. Just delete the action on the button. The button will look like it has no function but it actually works as the sign in button properly.
In the docs it says to use [self.signIn authenticate];
to start the sign in process. It doesn't say that if you use the GPPSignInButton
that it does this automagically. Grr :( Anyway, I've now fixed it by removing the code to sign in...
Hope this helps someone.
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