Class: OAuth

Oracle® JavaScript Extension Toolkit (JET)
5.0.0

E90577-01

QuickNav

OAuth

Version:
  • 5.0.0
Since:
  • 1.0.0
Module:
  • ojmodel
Member of Model objects. Object representing name/value pairs for a data service record

Constructor

new OAuth(attributes, header)

Parameters:
Name Type Description
attributes Object Initial set of attribute/value pairs with which to seed this OAuth object
header string Actual name for the Authorization header (default 'Authorization')
Examples

Initialize OAuth with client credentials

var myOAuth = new oj.OAuth('X-Authorization', {...Client Credentials ...});

Initialize OAuth with access_token

var myOAuth = new oj.OAuth('X-Authorization', {...Access Token...});

Initialize empty OAuth and set access_token

var myOAuth = new oj.OAuth();
myOAuth.setAccessTokenResponse({...Access Token...});

Methods

cleanAccessTokenRequest() → {undefined}

Clean request part of the OAuth object (client credentials, uri endpoint) Null and remove all data from request part of the OAuth object
Returns:
Type
undefined

cleanAccessTokenResponse() → {undefined}

Clean response part of the OAuth object (access_token, e.t.c.) Null and remove all data from response part of the OAuth object
Returns:
Type
undefined

clientCredentialGrant() → {undefined}

Request for access_token(bearer token) using Client Credential Authorization Grant. Initialize response part of the OAuth object (access_token, e.t.c.)
Returns:
Type
undefined
Example

Set/Re-set response part of the OAuth object using Client Credentials

myOAuth.clientCredentialGrant();

getAccessTokenRequest() → {Object}

Get request part of the OAuth object (client credentials, uri endpoint)
Returns:
cached request
Type
Object

getAccessTokenResponse() → {Object}

Get response part of the OAuth object (access_token, e.t.c.)
Returns:
cached response
Type
Object

getHeader() → {Object}

Calculates Authorization header based on client credentials or access_token
Returns:
OAuth 2.0 Authorization header
Type
Object
Example

Get Authorization header

myOAuth.getHeader();

isInitialized() → {boolean}

Check is OAuth initialized (not null access_token).
Returns:
true/false
Type
boolean
Example

Check if OAuth initialized

if(myOAuth.isInitialized()) console.log('Initialized');

setAccessTokenRequest(data) → {undefined}

Set request part of the OAuth object (client credentials, uri endpoint)
Parameters:
Name Type Description
data Object current client credentials and uri
Returns:
Type
undefined
Example

'Initialize' request part of the OAuth object with client credentials and calculate access_token

myOAuth.setAccessTokenRequest({...Client Credentials ...});
myOAuth.clientCredentialGrant();

setAccessTokenResponse(data) → {undefined}

Set response part of the OAuth object (access_token, e.t.c.)
Parameters:
Name Type Description
data Object current response
Returns:
Type
undefined
Example

'Initialize' response part of the OAuth object with access_token

myOAuth.setAccessTokenResponse({...Access Token...});