-
Google OAuth 2.0 integration- Server to Server
Objective
Platform should connect to Google services in a seamless manner so that every expected and initiated transactions can be executed successfully for every google cloud services that we are using or expected to be use in future.
Alternative approaches available (and their exploration)
There were following approaches we evaluated for the best fit, for our platform to consume- OAuth 2.0 web server Authentication
- OAuth 2.0 server to server Authentication
- Using OAuth 2.0 for Client-side Applications
Among these, we found the most practical to use for our platform on google cloud, was OAuth 2.0 server to server Authentication, as It supports the required server-to-server interactions such as those between platform and the Google service. Further it also supported seamlessly to use our own drive of service account for file and folder operation.
Delivery
- First to implement was a Google ‘service account’ (which is an account that belongs to your application instead of to an individual end user). Your application calls Google APIs on behalf of the service account, so users aren’t directly involved.
- A service account’s credentials include a generated google email address that is unique and at least one public/private key pair.
- Download the service account credential key in JSON format and create Google credential object to consuming Google services to connect to google cloud services
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream(“credential file path ”).createScoped(Collections.singleton(DriveScopes.DRIVE));
And we can use this Google credential object for other Google API requests by defining the API scope and enabling the API in google API library - Google cloud services that we connected to using OAuth 2.0
- Compute Instances
- Gmail
- Drive
- Static IPs
- Cloud DNS
- Google Identify and Access management (Iam).
- G Suite Admin SDK Directory API
Technology Stack Back-end Java Front-end No Front-end Middle-Tier Google Client libraries Framework None Methodology Agile- Scrum, Cultural DevOPS Delivery Success
We were able to automatically and seamlessly, create and manage any of above listed services upon action trigger (such new client sign up). Thus, propelling a self deploying application that with 2 minutes, rolls out an automatically deployed and ready to use application instance.
-
Google sheet Integration; Using Google Service Account
Objective
To execute full control over google sheet functionality through API calls so that it can be consumed as “Calculation Engine’ for the Financial Modelling complex calculations.
Delivery
Prerequisites; that were ready and available before coding
- Available Google OAuth 2.0 server to server credential to perform these operations
- Enable Sheets API on Google cloud library console
Delivered Feature set
- First created google Sheets Service object using the credential
Sheets sheets = new
Sheets.Builder(GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(),
credential).setApplicationName(GOOGLE_SHEET_MESSAGE).build(); - Used this Sheets object to create & manage following operations in google sheet
- Create new spreadsheets (with in folder or without folder)
- Delete or rename spreadsheets
- Rename spreadsheets
- Add, delete or rename sheet in an existing spreadsheet
- Rows and columns operations (insert, delete, update )
- Data update operations ( both single and batch updates)
- Data fetch from spreadsheets (both single and batch requests)
- Row or column formatting (both single and batch request)
Technology Stack Back-end Google Sheet API, Java 9 Front-end No Front-end Middle-Tier Google Client Libraries Framework Spring, Hibernate Methodology Agile- Scrum, DevOPS (Cultural) Delivery Success
All operations are successfully working since Feb 2017 without any issues and google sheet implementation becomes successful as as “Backend Calculation Engine’. As a result Client was able to raise intended funding and good number of new customers, based on these stable & performing provisions.
-
Google Drive Integrations
Objective
Client was using a dedicated drive account for each customer’s calculation engine i.e to store google sheet. It was therefore needed to automatically create the google drive for each new client’s google instance created and associate with the created instance.
Delivery
Prerequisites:
- Available Google OAuth 2.0 server to server credential to perform these operations
- Enable Drive API on Google cloud library console
Delivered Feature set
- Create google Drive Service object using the credentials
Drive driveService = new
Drive.Builder(GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(),
credential).setApplicationName(GOOGLE_SHEET_MESSAGE).build() - Used this Drive object we have done following operations on google Drive
- Created files and folder on drive
- Shared the files and folder to other users or provide selective permission
- Delete or rename files or folder on drive
- Rename files or folder on drive
- Upload files on drive with in folder or without folder
- Move files into and between the folders
Technology Stack Back-end Google Drive API, Java 9 Front-end No Front-end Middle-Tier Google Client Libraries Framework Spring, Hibernate Methodology Agile- Scrum, DevOPS (Cultural) Delivery Success
All operations are successfully working for a long time without any issues and clients drive is working as isolated drive for users data security purposes. There were not a single reported incident where one client was seeing other client’s data, till date, while this was implemented long back.
-
Google Directory API Create Google User Accounts
Objective
To create a google user account for the new client instance request
Exploration of possible solutions
Upon all candidate evaluations it was revealed that G Suite Admin SDK Directory API is the best way to create a google user account.Delivery
Prerequisites: that were ready and available before coding –
- Available Google OAuth 2.0 server to server credential to perform these operations
Delivered Feature set
- Using Google credential Object ) create Directory Object
List String SCOPES
=Arrays.asList(“https://www.googleapis.com/auth/admin.directory.user”);
Directory directory=new
Directory.Builder(GoogleNetHttpTransport.newTrustedTransport(),
JacksonFactory.getDefaultInstance(), google credential))
.setApplicationName(“google”).build(); - Following param values given along with the request
Family Name,Full Name,GivenName,PrimaryEmail,Password,CreationTime - Automation suite gets authenticated with google services with the Google OAuth 2.0 system
- Provides ability to automatically create ,delete and manage- a google user account
Technology Stack Back-end Java (Collections, FileInputStream) Google Directory API Front-end No Front-end Middle-Tier Google Client libraries Framework Spring, Hibernate Methodology Agile- Scrum, Cultural DevOPS Delivery Success
Solution seamlessly created the google users account along with their drives. Same was seamlessly associated with created client instance; thus providing quick rollout of customer useable instance.
-
Creating and Managing Google Service Accounts
Objective
Web application was needed to connect to Google cloud is an seamless manner. And it should create and manage service accounts that are in core to Google Cloud access.
Client can therefore access other google cloud services using this service account credential (a json file)Exploration of Possible Solutions
To create and manage service accounts using the Google Cloud’s Identity and Access Management i.e. we have used Google IAM API.
Delivery
To create & manage – Google Service Account
- Created the IAM service object
Iam iam Service =new Iam.Builder(httpTransport, GsonFactory.getDefaultInstance(), google credential).setApplicationName(“Iam”).build();
- Next made the request to Google Cloud IAM to create s service account by giving service account name or Id and provide the necessary roles and permissions
To download the required credential key (json file) for the future authentication and accesses
- Made the request to Google Cloud IAM by providing service account Id and created & downloaded the credential json format and it for future authentications
Technology Stack Back-end Java, JACKSON, Google IAM API Front-end No Front-end Middle-Tier Google IAM API Framework Spring, Hibernate Methodology Agile- Scrum, Cultural DevOPS Delivery Success
This credentials json is subsequently used for any of the Google Cloud services authentication and access; and that can be done is neat and seamless manner
- Created the IAM service object
-
Implement Google Compute Engine API
Objective
To create automatically the Google Compute Instance upon new client’s requests.
Exploration of Possible Solutions
Due to unique delivery model of the client (where each user of application gets customer set of modules); it was decided with client and management team to choose Google Cloud as an IAAS and consume the related google API named Google Compute Engine API
Delivery
To devise an engine that can automatically create (or delete) a Google Cloud VM using Compute Engine API. For this
- First we create a Static IP address and later set to for created instance. This calls for Google Cloud’s related network API i.e DNS API to be consumed- using Compute.Addresses.Insert with the attributes address(Name,Region,Kind)
- Create Google Compute services Object –
Compute compute= new Compute.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), set Http Timeout(GoogleCredential))
.setApplicationName(“Google-Compute Sample/0.1”).build(); - Prepared the request of Instance with following attributes Name,Zone,MachineType,CpuPlatform,ServiceAccounts, Disks, Address, NetworkInterfaces
- After instance is created, its access on internet needed to set, at this place we assigned the generated Static IP to the newly created instance.
Technology Stack Back-end Java, JACKSON, Google Compute Engine API Front-end No Front-end Middle-Tier Google Compute Engine API, Google IAM API, Google DNS API Framework Spring, Hibernate Methodology Agile- Scrum, Cultural DevOPS Delivery Success
As and when new client has signed up, this functionality automatically created a new Google Compute and made it accessible over internet, immediately.
-
Google Cloud DNS API integration
Objective
In order to automatically create Google Compute Instance upon new client’s requests, it’s also required to set its access over internet via domain name assigned to it.
Delivery
For the domain name registration, we have used the Google Cloud DNS services API.
- Create or register and deregister DNS of an VM on google cloud using DNS API
Create Google DNS Services Object as followsDns dnsService= new Dns.Builder(GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), set Http Timeout(GoogleCredential))
.setApplicationName(“Google-DnsSample/0.1”).build(); - Prepared an request of DNS with following attributes
Kind, Name, TTL, Type, IP address of instance - Registered DNS for the VM using DNS.change().create method using attributes
projectId,Zone, and the prepared request Body
DNSService.changes().create(“cloud project Id”,”Zone”, requestBody).execute();
Technology Stack Back-end Java , JACKSON , Google CLOUD DNS API Front-end No Front-end Middle-Tier Google Client libraries Framework Spring, Hibernate Methodology Agile- Scrum, Cultural DevOPS Delivery Success
While creating the instance the domain names were seamlessly assigned to the instance and it was readily accessible over internet. (Similarly when subscriptions were terminated by the any clients, the reverse/deletion process takes place).
- Create or register and deregister DNS of an VM on google cloud using DNS API
-
Google Kuberntes
Objective
Delivery
Technology Stack Back-end Java, MySQL Front-end HTML5, CSS3, Bootstrap 3, (Minor- JavaScript, JQuery) Middle-Tier None Framework Spring 5, Hibernate 5 Methodology Agile- Scrum, DevOPS Delivery Success
-
AppEngine
Objective
Delivery
Technology Stack Back-end Java, MySQL Front-end HTML5, CSS3, Bootstrap 3, (Minor- JavaScript, JQuery) Middle-Tier None Framework Spring 5, Hibernate 5 Methodology Agile- Scrum, DevOPS Delivery Success
-
Google Functions
Objective
Delivery
Technology Stack Back-end Java, MySQL Front-end HTML5, CSS3, Bootstrap 3, (Minor- JavaScript, JQuery) Middle-Tier None Framework Spring 5, Hibernate 5 Methodology Agile- Scrum, DevOPS Delivery Success