Skip to content

GetTokenAsync Method ​

Definition ​

  • Namespace: JASE.ServiceNow
  • Assembly: JASE.ServiceNow.dll

Overloads ​

NameDescription
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, ClientCredentialsTokenRequest request, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, IOAuthTokenRequest request, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, PasswordTokenRequest request, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the resource owner password credentials grant.
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string scope, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string username, string password, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the password grant (resource owner password credentials).
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string username, string password, string scope, CancellationToken cancellationToken = null)Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the password grant (resource owner password credentials).

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, ClientCredentialsTokenRequest request, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, ClientCredentialsTokenRequest request, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
contextConnection context containing the ServiceNow instance base URL.
requestClientCredentialsTokenRequest detailing the request information

Returns ​

An AuthenticationTokenResult containing the access token and expiration.

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, IOAuthTokenRequest request, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, IOAuthTokenRequest request, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
contextConnection context containing the ServiceNow instance base URL.

Returns ​

An AuthenticationTokenResult containing the access token and expiration.

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, PasswordTokenRequest request, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, PasswordTokenRequest request, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the resource owner password credentials grant.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
contextConnection context containing the ServiceNow instance base URL.
requestPasswordTokenRequest detailing the request information

Returns ​

An AuthenticationToken containing the access token and expiration.

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string username, string password, string scope, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string username, string password, string scope, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the password grant (resource owner password credentials).

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
clientIdOAuth client ID from the Application Registry.
clientSecretOAuth client secret from the Application Registry.
contextConnection context containing the ServiceNow instance base URL.
passwordServiceNow password for username.
scopeOptional OAuth scope (e.g. useraccount). Required on many instances for Table API access.
usernameServiceNow username (sys_user.user_name).

Returns ​

An AuthenticationTokenResult containing the access token, expiration, and (optionally) a refresh token.

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string username, string password, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string username, string password, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the password grant (resource owner password credentials).

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
clientIdOAuth client ID from the Application Registry.
clientSecretOAuth client secret from the Application Registry.
contextConnection context containing the ServiceNow instance base URL.
passwordServiceNow password for username.
usernameServiceNow username (sys_user.user_name).

Returns ​

An AuthenticationTokenResult containing the access token, expiration, and (optionally) a refresh token.

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string scope, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, string scope, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
clientIdOAuth client ID from the Application Registry.
clientSecretOAuth client secret from the Application Registry.
contextConnection context containing the ServiceNow instance base URL.
scopeOptional OAuth scope (e.g. useraccount). Sent as the scope form field when non-empty.

Returns ​

An AuthenticationTokenResult containing the access token and expiration.

Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, CancellationToken cancellationToken = null) ​

csharp
Task<AuthenticationTokenResult> GetTokenAsync(ConnectionContext context, string clientId, string clientSecret, CancellationToken cancellationToken = null)

Requests an OAuth 2.0 access token from the ServiceNow token endpoint (/oauth_token.do) using the client_credentials grant.

Parameters ​

NameDescription
cancellationTokenToken used to cancel the request.
clientIdOAuth client ID from the Application Registry.
clientSecretOAuth client secret from the Application Registry.
contextConnection context containing the ServiceNow instance base URL.

Returns ​

An AuthenticationTokenResult containing the access token and expiration.