GetOIDCAccessToken (NotesSession - LotusScript)

It is used to acquire an access token from a Domino OIDC Provider for the current user as identified and authenticated by their ID file.

Defined in

NotesSession

Syntax

token$ = session.GetOIDCAccessToken(server$, clientid$, issuer$, resource$, scope$)

Parameters

server$

String. Name of Domino Server to contact.

Clientid$

String. The client ID for your OAuth application.

issuer$

String. Your issuer (Domino OIDC provider if empty string).

resource$

String. Requested resource (First configured audience for client if empty string)

scope$

String. Requested scopes (Configured scopes for client if empty string)

Return value

token$

String. The access token.

Example

This sample code show simple script to get OIDC Access Token
Option Declare

Sub Initialize

Dim Session As New NotesSession
Dim Server As String
Dim ClientID As String
Dim Issuer As String
Dim Resource As String
Dim Scopes As String
Dim Token As String

On Error GoTo error_handler

Server = "oidc.example.org"
ClientID = "oidc-example-org"
Issuer = "https://oidc.example.org/auth/protocol/oidc"
Resource = ""
Scopes = ""

MessageBox "User Name: "& session.UserName

Token = session.getOIDCAccessToken (Server, ClientID, Issuer, Resource, Scopes)

MessageBox "OIDC Token: "& Token
Exit Sub

error_handler:

MessageBox "Error " & Err & ": " & Error$
Exit Sub

End Sub
This sample show End to end with requesting a resource
Option Public
Option Declare


Sub Initialize

On Error GoTo error_handler

Dim session As New NotesSession
Dim http As NotesHTTPRequest

Dim Server As String
Dim ClientID As String
Dim Issuer As String
Dim Resource As String
Dim Scopes As String
Dim Token As String
Dim Url As String
Dim Response As String

' --- OIDC configuration ---
Server = "oidc.example.org"
ClientID = "oidc-example-org"
Issuer = "https://oidc.example.org/auth/protocol/oidc"
Resource = ""
Scopes = ""

MessageBox "User Name: " & session.UserName

' --- Get OIDC access token ---
Token = session.GetOIDCAccessToken(Server, ClientID, Issuer, Resource, Scopes)

If Token = "" Then
Error 1000, "No OIDC access token returned"
End If

Url = "https://domino.example.org/sampleDB.nsf"

Set http = session.CreateHTTPRequest()

http.SetHeaderField "Authorization", "Bearer " & Token
http.SetHeaderField "User-Agent", "HCL Notes 14.5.1 OIDC Test"

Response = http.Get(Url)

MessageBox "HTTP Status: " & http.ResponseCode & Chr(10) & Chr(10) & "Response:" & Chr(10) & Response

Exit Sub

error_handler:

MessageBox "Error " & Err & ": " & Error$
Exit Sub

End Sub