OAuthAPI APIs

The OAuthAPI library provides functions for working with OAuth.

Table 1. Initialization functions
Function Description
Init( 
   cnx_timeout INTEGER, 
   client_id STRING,
   client_secret STRING )
  RETURNS BOOLEAN 
To be called in a Genero app accessing a secure RESTful Web service started behind a Genero Application Server.
InitService( 
   cnx_timeout INTEGER, 
   access_token STRING )
  RETURNS BOOLEAN 
To be called in a Genero Web service started via OpenID Connect accessing another secure RESTful Web service as a client.
Table 2. Metadata functions
Function Description
GetOpenIDMetadata()
RETURNS OAuthAPI.OpenIDMetadataType
Get metadata from the Identity Provider for a service running on a Genero Application Server (GAS).
Table 3. ID token metadata functions
Function Description
GetIDPIssuer()
RETURNS STRING
Get endpoint of the Identity Provider.
GetIdRoles()
RETURNS DYNAMIC ARRAY OF STRING
Get OAuth ID Token authorization roles.
GetIDScopes()
RETURNS DYNAMIC ARRAY OF STRING
Get OAuth ID Token authorization scopes.
GetIDSubject()
RETURNS STRING
Get OAuth subject identifier of ID Token.
Table 4. Access token functions
Function Description
GetMyAccessToken()
RETURNS STRING
Get a valid access token.
Table 5. Authorization request functions
Function Description
CreateHTTPAuthorizationRequest(
   url STRING )
RETURNS com.HttpRequest
Create an HttpRequest with OAuth access token.
RetryHTTPRequest(
resp com.HttpResponse )
RETURNS BOOLEAN
Retry an HttpRequest with OAuth access token to check if the access token has expired.
Table 6. Helper functions
Function Description
ExtractTokenFromHTTPRequest(
req comm.HttpServiceRequest)
RETURNS STRING
Return the OAuth access token.
FetchOpenIDMetadata(
   timeout INTEGER, 
   idp STRING )
RETURNS OAuthAPI.OpenIDMetadataType
Fetch metadata from the Identity Provider at the URL provided.
RetrievePasswordToken(
   timeout INTEGER,
   TokenServiceURL STRING, 
   usr, STRING, 
   pass STRING,
   scope STRING )
RETURNS ( STRING, INTEGER )
Return the OAuth service access token via user name and password.
RetrieveServiceToken(
   timeout INTEGER,
   TokenServiceURL STRING, 
   client_id STRING, 
   secret_id STRING,
   scope STRING )
RETURNS STRING, INTEGER
Return the OAuth service access token via client app credentials.