K2 Google G Suite Integration [EN Version]

Credit of this blog goes to withsp

Hello today we’ll talk about integration between K2 and Google GSuite. Pre-requisite as below

  • K2 Five version 5.0001.1000.1 or above (version date is 28 Nov 2017)
  • Google account

Firstly, we need to prepare google service that we want to intergrate with. Url for enable service is https://console.developers.google.com/apis. You need to signin with google account. Click Library tab on the left.

google01

In our example we’ll use Google Drive API.

google02

Click Enable button

google03

Then go to tab Credentials and select OAuth consent screen. Select your email and enter Product Name

google05

After Save click at Credentials again and select Create credentials => OAuth client ID

google06

In Create client ID screen select Application Type as Web application and input Name. Input Authorised JavaScript origins as your K2 site url and Authorised redirect URIs as K2 site url append with /identity/token/oauth/2

google07

After created, we’ll get Client ID and Client secret. These will use to register with K2. So we’ll finish setup Google side.

google08

Open your K2 management site and navigate to Authentication => OAuth => Resource Types. Create your new OAuth Resource Type

google10

Next step is create Resource Type Parameters at the bottom view

google11

After finish, navigate to OAuth => Resources. Create your new OAuth Resource and select Resource Type as your created resource from previous step. Input Authorization Endpoint as https://accounts.google.com/o/oauth2/auth and Token Endpoint as https://accounts.google.com/o/oauth2/token

google12

Next step is configure parameter for OAuth Resource

  • client_id and client_secret input information that we got from Google.
  • response_type input Authorization Value as code
  • scope input as https://www.googleapis.com/auth/drive
  • redirect_uri input Authorization Value and Token Value as K2 site url append with /identity/token/oauth/2
  • grant_type input Token Value as authorization_code
  • access_type input Authorization Value and Token Value as online

google13

After finish we’ll have OAuth resource ready to use in service instance configuration. For configure REST service instance we need to have json of service that we want to use. For Google Drive we can search at  https://apis.guru/browse-apis/

google14

Next step we’ll register REST service. Select Authentication Type as OAuth and select our OAuth Resource from previous step

google15

google16

If we found above error, don’t be panic. After you finish OK, system will open browser for you to authentication with google. After you input username password and follow instruction on screen. You will navigate to Authorization Successful screen.

google17

Try adding service instance again. You should be able to create new service instance. Then you can create SmartObject to get data from Google Drive as expected.

google18

Step for create OAuth in K2 reference from https://help.k2.com/kb001702. Google API document can found in google website that you for enable services. If you have question, please feel free to ask. See you next time 🙂

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s