OAuth Token Generation and Use

Background Information about OAuth

See this Wikipedia article for background information about OAuth:

https://en.wikipedia.org/wiki/OAuth

Invoking Oracle Primavera Cloud Data Service hosted on Oracle Cloud Infrastructure (oraclecloud.com)

In order to invoke the Oracle Primavera Cloud Data Service hosted on Oracle Cloud Infrastructure, first generate an OAuth token using Basic authentication, then you use the OAuth token to access the API.

Authentication

The Basic authentication scheme uses a username and password.

The Bearer authentication scheme uses an OAuth token.

  • To access Oracle Primavera Cloud Data Service using Basic authentication, the user needs to provide a username and password.
  • To access Oracle Primavera Cloud Data Service using OAuth, the user needs to provide a Bearer token along with 'x-prime-identity-app' and 'x-prime-tenant'.

OAuth token generation using Basic Authentication

Use the primediscovery endpoint, as shown below, to generate an OAuth access token. This endpoint can be invoked with Basic authentication of a valid user/password on Oracle Cloud Infrastructure that has been provisioned into Oracle Primavera Cloud.

Scope must be the full path (always http) to the context root of the application - http://<host>:<port>/data.

Example using CURL

curl -X POST -k -H 'Authorization: Basic <BASE64_ENCODED_USERNAME_PASSWORD>' -i 
'https://<host>:<port>/primediscovery/apitoken/request?scope=http://<host>:<port>/data'

Response Payload

{
   "accessToken": "eyJ4NXQjU...2gLZVQ",
   "primeTenant": "idcs-d9c5e846631a4fa387b7e012a76b6370",
   "primeTenantCode": "123456",
   "userName": "user@corp.com",
   "userId": "9521f5927a96409fbdatadc29e4cea089",
   "primeIdentityApp": "primeprojectswtssapp_APPID",
   "expiresIn": 3600
}

Using the OAuth generated OAuth token to invoke the Oracle Primavera Cloud Data Service using Bearer Authentication

Using the access token generated using Basic authentication, along with the header 'x-prime-identity-app', the Data Service can be invoked as shown below.

Exampe Using curl

curl -X GET https://<host>:<port>/data/rest/dataservice/tables
	-H 'Authorization: Bearer eyJ4NXQjU...2gLZVQ'
	-H 'Content-Type:application/json'
	-H 'Version:3'
	-H 'x-prime-identity-app:primeprojectswtssapp_APPID'
	-H 'x-prime-tenant:idcs-d9c5e846631a4fa387b7e012a76b6370'
	-H 'x-prime-tenant-code:123456'