Google+ Sign In for iOS

Hello Team -
I’m implementing Google Authentication for my iOS App using Native Google SDK’s. Once the authentication is done, I have implemented the following code in signIn delegate. When i try to test the same, i get fault code :FAULT = ‘9022’ [Malformed JWS, unable to decode signature] <Malformed JWS, unable to decode signature> error.
Is loginWithGooglePlusSDK method supported for iOS? If so, can you please let me know if i’m doing anything wrong or point me to the right documentation?

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
 
 if (error == nil) {
 
 // Perform any operations on signed in user here.
 let userId = user.userID
 let accessToken = user.authentication.idToken
 let permissions = ["email"]
 
 let fieldsMapping = [
 "name": "name",
 "email": "email"
 ]
 
 backendless.userService.loginWithGooglePlusSDK(userId, accessToken: accessToken, permissions: permissions, fieldsMapping: fieldsMapping,
 response: {
 (user: BackendlessUser!) -> Void in
 print("user :\(user)")
 }, error: {
 (fault: Fault!) -> Void in
 print("fault code :\(fault)")
 }
 )
 }

Can you please confirm if this method works? I couldnt find any documentation around…

Hi, Arasan.

We’ll get in touch with you soon.

Hi Arasan,

We are working for loginWithGooglePlusSDK demo sample.
Now you can use easyLoginWithGooglePlusFieldsMapping: - here is sample.

Regards,
Slava

Can you send your project (or sample) demonstrated this issue to support@backendless.com, I will investigate it and fix this problem asap.

Or upload your project to Google Drive or Dropbox, and send the link.

Hi Vyacheslav - Thanks for looking into this issue. I have uploaded the project into google drive and shared the link with you via email (support@backendless.com). I saw the easyLoginWithGooglePlusFieldMapping but wanted to try using the Google SDK for few other reasons. Let me know how to make it work.

Thanks,
Arasan

Hi Arasan,

Please update Backendless SDK from CocoaPods (3.0.10 release) and fix your method:

    func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
        withError error: NSError!) {
            if (error == nil) {
                
                // Perform backendless operations on signed in user here.
                let idToken = user.authentication.idToken
                let accessToken = user.authentication.accessToken
                
                print("idToken = '\(idToken)'")
                print("accessToken = '\(accessToken)'")
                
                let permissions = ["email"]
                let fieldsMapping = [
                "name": "name",
                "email": "email"
                ]
                
                backendless.userService.loginWithGoogleSignInSDK(idToken, accessToken: accessToken, permissions: permissions, fieldsMapping: fieldsMapping,
                    response: {
                        (user: BackendlessUser!) -> Void in
                        print("user :\(user)")
                    }, error: {
                        (fault: Fault!) -> Void in
                        print("fault code :\(fault)")
                    }
                )
                
            } else {
                print("\(error.localizedDescription)")
            }
    }

Let we know how it goes.

Regards,
Slava

Also you should set the Google API options on a dashboard of your Backendless app (in Social Settings):

http://support.backendless.com/public/attachments/39bc68f4d7f41d3c7454e2a9de029d6b.png&lt;/img&gt;
using GoogleService-Info.plist data from your project:
http://support.backendless.com/public/attachments/4c5bd7500a3abc5d72b9819e2b89417e.png&lt;/img&gt;

Hi Vyacheslav -

I tried updating the Backendless version to 3.0.10, but i get a different error right now.

fault code :FAULT = ‘9010’ [Invalid social identity] <Invalid social identity>

I looked at your social settings configuration, looks like you have copied the CLIENT_ID and REVERSE_ID to Google Plus ID and Google Plus Secret. Is this correct? I have copied the CLIENT_ID and CLIENT_SECRET from google console and it works with easyLoginWithGooglePlusFieldsMapping method.

Can you please advice?

Arasan

G-ID.png

Hi Arasan,

Please see screenshots above - you should set the Google options of the Social Setting bookmark on your Backendless app dashboard so, that they will be associated with GoogleService-Info.plist options from your project:
‘Google Plus ID’ = CLIENT_ID
‘Google Plus Secret’ = REVERSED_CLIENT_ID

BTW, these GoogleService-Info.plist options correspond with data on Google Dev console
http://support.backendless.com/public/attachments/212673422288a49da3b72631e17a6d83.png&lt;/img&gt;

Regards,
Slava

I’ve shared by my GoogleSignIn sample project - it works fine for me, you can try it and check all settings. Let me know how it goes for you.

Hi Slava -

Thanks for the quick response. I tried updating the backendless Google Keys and still get the same error.

fault code :FAULT = ‘9010’ [Invalid social identity] <Invalid social identity>

Thanks,
Arasan

updated-GSign.png

Please check if your app Bundle Identifier corresponds with one on Google Dev console - Credentials - “iOS client for <bundle ID>”.

Also you could create new Google app (with your bundle ID) & new Backendless app - and try again.

I see you’ve done with my app:

http://support.backendless.com/public/attachments/ad353fb787dca0adc0038f719e11a89d.png&lt;/img&gt;

Hi Vyacheslav -

Thank you so much for quickly resolving the issue. Its working now…

Thanks,
Arasan

Please explain about Login with Google in Android