AWS for Industries
Subsurface data management: How to authenticate OSDU on AWS sandbox
Introduction
Data is fueling subsurface innovation, yet getting the data into a format that enables novel analytical approaches and enables end users to focus on using novel data insights to solve problems is a key challenge. The Open Group OSDU™ Forum is developing a standard data platform for the oil and gas industry, which will reduce data silos and put data at the center of the subsurface community.
OSDU on AWS is a secure, reliable, cost-effective, and performant implementation of the OSDU standard. With OSDU on AWS, companies can focus on the truly differentiating parts of their business, and leave the undifferentiated heavy lifting of subsurface data management to AWS.
This blog explains how to authenticate to your OSDU on AWS sandbox. We will create a simple Node.js application which authenticates to your OSDU on AWS sandbox.
Overview of solution
This blog is designed to support customers who have recently installed an OSDU on AWS environment and must authenticate their environment in order to search and consume data. This is the first blog post in a series that will provide support for getting started with your OSDU on AWS environment.
In this post, we explain how to authenticate to your OSDU on AWS sandbox. To do this, we will create a simple Node.js application and authenticate to your OSDU on AWS sandbox. This will enable OSDU on AWS for a range of functionality including searching and data ingestion.
Prerequisites:
To build and deploy the solution, you will need:
- An OSDU on AWS deployment with Release 2 installed and configured in an AWS account, and credentials (user name and password) to access the platform.
- TNO and Volve data loaded into your OSDU on AWS account.
- Download and install Node.js.
- Download and install Visual Studio Code IDE.
Solution
To build out the solution, we will be working both on the AWS Management Console and on your local machine. We will first create the Node.js application, then authenticate to your OSDU on AWS sandbox.
Section 1: Create the Node.js application
- Open a command prompt or terminal and create a directory for your Node.js application. Then switch to the directory as shown.
- Run the npm init –y command to setup an npm (Node package manager) package with default values.You should see a package.json file created in the directory with the values shown in the previous screenshot.
- Open Visual Studio Code IDE. Open the folder where you created the Node.js package as shown.
- You will now see your folder under Explorer with the package.json file as shown.
- Create a new file in your folder that contains the package.json file and name it index.js. View the following screenshots for reference.
You will see the new file saved as index.js as shown.
- Copy the following code to the index.js file.
Section 2: Authenticate to your OSDU on AWS account
- In the code from step 6, replace the <User Name> and <Password> place holders with your Amazon Cognito user name and password provided to you. If you do not have a <User Name> and <Password> reach out to your OSDU on AWS contact.
- Replace the <Cognito User PoolId> and <Cognito Client Id> placeholders with your Amazon Cognito User Pool ID and Amazon Cognito ClientID.You can find your Amazon Cognito User Pool ID by going to Amazon Cognito page and -> click on Manage User Pools as shown.
Click on the osduonaws-UserPool as shown:
- You will be taken to the General settings on the User Pool page. Copy the Pool ID as shown below and replace the <Cognito User PoolId> placeholder in your code with it.
- Click on App client settings under App integration.
- Scroll down until you find App client osduonaws-DefaultAppClient. Copy the Client ID and replace the <Cognito Client Id> placeholder in your code with it. It is very important you copy the DefaultAppClient Client ID and not the ClientSecret ID, otherwise you will not be able to connect.
- Make sure you have also replaced the <User Name> and <Password> placeholders with your correct Amazon Cognito user name and password provided to you.
- Replace the contents of the package.json file with the code below that contains dependencies required by the application.
- Open a new Terminal in Visual Studio Code as shown.You will see the new Terminal Window below the code.
- Run the npm install command to download the dependencies as shown.
- You will see the dependency packages installed.
- Run the command node index.js as shown.
- Once you are authenticated you will see the Access Token as shown.
Code Walkthrough
As you have successfully authenticated to the OSDU on AWS sandbox, we will now go over the code. Starting from the beginning, the following code imports the dependencies.
The code below authenticates the user and returns an access token.
Conclusion
In this blog, we have demonstrated authenticating to OSDU on AWS sandbox using JavaScript and Node.js. Once this is complete, you will be able to search for data from your OSDU on AWS sandbox, which will be demonstrated in a future blog post.