Appearance
GetTokenAsync Method
Definition
- Namespace:
JASE.ServiceNow - Assembly:
JASE.ServiceNow.dll
Overloads
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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
context | Connection context containing the ServiceNow instance base URL. |
request | ClientCredentialsTokenRequest 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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
context | Connection 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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
context | Connection context containing the ServiceNow instance base URL. |
request | PasswordTokenRequest 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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
clientId | OAuth client ID from the Application Registry. |
clientSecret | OAuth client secret from the Application Registry. |
context | Connection context containing the ServiceNow instance base URL. |
password | ServiceNow password for username. |
scope | Optional OAuth scope (e.g. useraccount). Required on many instances for Table API access. |
username | ServiceNow 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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
clientId | OAuth client ID from the Application Registry. |
clientSecret | OAuth client secret from the Application Registry. |
context | Connection context containing the ServiceNow instance base URL. |
password | ServiceNow password for username. |
username | ServiceNow 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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
clientId | OAuth client ID from the Application Registry. |
clientSecret | OAuth client secret from the Application Registry. |
context | Connection context containing the ServiceNow instance base URL. |
scope | Optional 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
| Name | Description |
|---|---|
cancellationToken | Token used to cancel the request. |
clientId | OAuth client ID from the Application Registry. |
clientSecret | OAuth client secret from the Application Registry. |
context | Connection context containing the ServiceNow instance base URL. |
Returns
An AuthenticationTokenResult containing the access token and expiration.