[Google Login Plugin] How to Configure the Google Plus Login Plugin for iOS

[Google Login Plugin] How to Configure the Google Plus Login Plugin for iOS

  
Forge Component
(6)
Published on 6 Jul by OutSystems Labs
6 votes
Published on 6 Jul by OutSystems Labs

With the Google Plus Login, you can integrate a Google login plugin in your application, easing the login process, and making it unnecessary to create a new account.

Follow the steps below to configure the Google Plus login plugin.

1. Go to the Google API Manager console and log in using your Google credentials.

2. Create a new project.


3. Enter your app's name in the name input.

4. Select and enable the Google + API.


5. Click the Create credentials button.


6. Add credentials to your project.
    a. Select Google+ API in the kind of credentials you need.
    b. Select Web server (e.g. node js, Tomcat) as the setting you'll need to configure.
    c. Choose User data as the data you will be accessing.
    d. Click the What credentials do I need? button.


7. Add authorized redirect URIs.
    a. To authorize all the URLs from the server, add “/*” in Authorized redirect URIs.
    b. To authorize a specific app, add to the URL, the application name and in the end, add “/*” to authorize all application screens.


8. Add the product name that the users will see.


9. Save the Client ID. You will need it during the Android configuration.
Click Done.


The following steps are iOS-specific.

1. Go to Enable Google services for your iOS app.

2. Choose the App Name (this should be the same name that you gave to the project), and enter the application identifier (the same as your iOS certificate).


3. Click Enable Google Sign-in.

4. A new iOS key and OAuth 2.0 client ID for iOS appear when you refresh the console page. Copy the schema from iOS - OAuth 2.0 client IDs.


Extensibility Configuration JSON:

"
{
    "plugin":
        {
            "url": "https://github.com/EddyVerbruggen/cordova-plugin-googleplus#5.0.3",
            "variables": [{
                "name": "REVERSED_CLIENT_ID",
                "value": "{iOS URL scheme}"
            }]
        }
}
"


5. Return to the browser, copy the Client ID from WebClient1. You will need it later.

6. Reference all actions from the GoogleLoginPlugin. Drag the GoogleLogin action to your client side login action.

7. Define the following parameters, only two are mandatory:

  • IsSilent: Check if the user is already signed in to the app and sign them in silently if they are. You should use the default: False. Change it to True, only if you are sure that the user is already logged in through Google Login.

  • Scopes: The default scopes requested are the profile and the email. To request other scopes, add them as a space-separated list. Refer to the Google Scopes documentation for info on valid scopes that can be requested. Default:
    "https://www.googleapis.com/auth/plus.login
    https://www.googleapis.com/auth/userinfo.email
    https://www.googleapis.com/auth/plus.me 
    https://www.googleapis.com/auth/userinfo.profile"

  • ClientId: It's the webClientId value from your Google account/project. It identifies the target account to log in to. This field is mandatory.

  • Offline: Optional, but requires the ClientId. If set to True the plugin will also return a serverAuthCode, which can be used to grant offline access to a non-Google server.

  • ForceApprovalPrompt: Forces the permission popup to appear in each login. Default value: False.

  • IsMapUsers: If True, it means that you want to map the user between the client and the server side. This field is mandatory.

  • OneToOneEmailMapping: Ensures that the given email only matches one user on the server database. Default value: False.

  • CreateGoogleUsers: Ensures that the plugin can create a server user to matches the given email if no user is found.

8. The GoogleLogin action validates the Google account, however, if you want a system login you should code that. Google Core provides you with an action to do that, and it’s explained above.

9. Reference Google Core actions and drag ValidateAndLoginGoogleUser action after the GoogleLogin action.
ValidateAndLoginGoogleUser has the following input parameters: 

  • IdToken: GoogleLogin action returns an IdToken when it’s successful.
  • UserId: GoogleLogin user ID.
  • IsPersistent: If True, the login will be persistent for 15 days.

10. After you call this action, your user is logged in using the OutSystems login, so you can GrantRoles and manage it as you want.

11. The Google Login Plugin is ready. Publish your app.