Object -
oauth2
:
OutboundOAuth2Provider
Represents the outbound OAuth2 provider, which generates OAtuh2 tokens. This supports the client credentials grant type,
password grant type, and the direct token mode, which sends the access token directly.
The oauth2:OutboundOAuth2Provider
is an implementation of the auth:OutboundAuthProvider
interface.
- Client Credentials Grant Type
oauth2:OutboundOAuth2Provider oauth2Provider1 = new({
tokenUrl: "https://localhost:9196/oauth2/token",
clientId: "3MVG9YDQS5WtC11paU2WcQjBB3L",
clientSecret: "9205371918321623741",
scopes: ["token-scope1", "token-scope2"]
});
- Password Grant Type
oauth2:OutboundOAuth2Provider oauth2Provider5 = new({
tokenUrl: "https://localhost:9196/oauth2/token/authorize/header",
username: "johndoe",
password: "A3ddj3w",
clientId: "3MVG9YDQS5WtC11paU2WcQjBB3L",
clientSecret: "9205371918321623741",
scopes: ["token-scope1", "token-scope2"]
});
- Direct Token Mode
oauth2:OutboundOAuth2Provider oauth2Provider13 = new({
accessToken: "2YotnFZFEjr1zCsicMWpAA",
refreshConfig: {
refreshUrl: "https://localhost:9196/oauth2/token/refresh",
refreshToken: "XlfBs91yquexJqDaKEMzVg==",
clientId: "3MVG9YDQS5WtC11paU2WcQjBB3L",
clientSecret: "9205371918321623741",
scopes: ["token-scope1", "token-scope2"]
}
});
Constructor
__init
(GrantTypeConfig? oauth2ProviderConfig)
- oauth2ProviderConfig GrantTypeConfig? ()
-
Outbound OAuth2 provider configurations
Methods
Fields
- oauth2ProviderConfig GrantTypeConfig?
-
Outbound OAuth2 provider configurations
- oauth2CacheEntry OutboundOAuth2CacheEntry
-
Outbound OAuth2 cache entry
Generate a token for the OAuth2 authentication.
string:auth:Error token = outboundOAuth2Provider.generateToken();
-
Return Type
(string | Error) Generated
string
token or else anauth:Error
if an error occurred
Inspects the incoming data and generates the token for the OAuth2 authentication.
string:auth:Error? token = outboundOAuth2Provider.inspect(data);
Parameters
- data map
-
Map of data, which is extracted from the HTTP response
-
Return Type
(string | Error | ()) Generated
string
token, anauth:Error
occurred while generating the token, or else()
if nothing is to be returned