User authenticating with GAS/SSO/GIP

Provides a code example for initializing SSO user authentication using OAuthAPI, including fetching metadata, retrieving a password token, and initializing a native app with user credentials.

Use the following code, to initialize the SSO user identification with OAuthAPI:
 DEFINE metadata OAuthAPI.OpenIDMetadataType
 DEFINE tokens OAuthAPI.OpenIdCResponseType
 DEFINE user_login, user_pswd STRING
 DEFINE r BOOLEAN

 -- Initialize user_login and user_pswd (from a login dialog for example)
 CALL dbsync_core.enter_user_credentials("SSO/GIP login",NULL)
      RETURNING s, user_login, user_pswd
 IF s<0 THEN EXIT PROGRAM 0 END IF

 CALL OAuthAPI.FetchOpenIDMetadata(5, dbsync_source.sso.idp_issuer)
      RETURNING metadata
 IF metadata.issuer IS NULL THEN
     DISPLAY "ERROR: Could not fetch OAuthAPI.OpenIDMetadataType"
     EXIT PROGRAM 1
 END IF

 CALL OAuthAPI.RetrievePasswordTokenForNativeApp(5, metadata.token_endpoint,
                                                 user_login, user_pswd,
                                                 dbsync_source.sso.client_id,
                                                 dbsync_source.sso.client_secret,
                                                 NULL)
          RETURNING tokens

 LET r = OAuthAPI.InitNativeApp(5, tokens,
                                dbsync_source.sso.client_id,
                                dbsync_source.sso.client_secret,
                                metadata.token_endpoint)
 IF NOT r THEN
     DISPLAY "ERROR: Could not initialize native app with OAuthAPI.InitNativeApp"
     EXIT PROGRAM 1
 END IF