# FetchAccessToken

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.ServiceNow/tree/main/Frends.ServiceNow.FetchAccessToken>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Url : `String`                  | <p>The base URL to the ServiceNow instance.</p><p><br>Default: <code>-</code><br>Example: <code><https://dev123456.service-now.com></code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| GrantType : `GrantType`         | <p>Grant type determines how the access token is fetched for ServiceNow.</p><p>Possible values:</p><ul><li><code>Password</code>:</li></ul><p>Grant type determines how the access token is fetched for ServiceNow.</p><ul><li><code>Refresh\_token</code>:</li></ul><p>Grant type determines how the access token is fetched for ServiceNow.</p><ul><li><code>Custom</code>:</li></ul><p>Grant type determines how the access token is fetched for ServiceNow.</p><p><br>Default: <code>-</code><br>Example: <code>Frends.ServiceNow\.Definitions.GrantType.Password</code></p> |
| ClientId : `String`             | <p>ServiceNow instance Client Id.</p><p><br>Default: <code>-</code><br>Example: <code>1ab23456c789ded785dhd</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| 🗝ClientSecret : `String`       | <p>ServiceNow instance Client Secret.</p><p><br>Default: <code>-</code><br>Example: <code>HBF78cfbe6?</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Username : `String`             | <p>ServiceNow instance username.</p><p><br>Default: <code>-</code><br>Example: <code>integration.user</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| 🗝Password : `String`           | <p>ServiceNow instance password.</p><p><br>Default: <code>-</code><br>Example: <code>cvj#renivreb7tycv4e8!cv7reb8v47382?</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| 🗝RefreshToken : `String`       | <p>RefreshToken for ServiceNow instance. You can get the refresh token when initially fetched the access token with password grant type.</p><p><br>Default: <code>-</code><br>Example: <code>5FDughf\_ncuenUJbvcerubn67cbe-fjncer8c7efcbE88fcvbvc48vbncsifb\_kbncUgbE9FCVBE</code></p>                                                                                                                                                                                                                                                                                           |
| Properties : `CustomProperty[]` | <p>Array of custome properties for the url encoded message.</p><p><br>Default: <code>-</code><br>Example: <code>\[ { Name: CustomName, Value: CustomValue } ]</code></p>                                                                                                                                                                                                                                                                                                                                                                                                         |
| {% endtab %}                    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

{% tab title="Parameter: Options" %}

| Name                                               | Description                                                                                                                                                                                          |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ConnectionTimeoutSeconds : `Int32`                 | <p>Timeout in seconds to be used for the connection and operation.</p><p><br>Default: <code>30</code><br>Example: <code>30</code></p>                                                                |
| FollowRedirects : `Boolean`                        | <p>If FollowRedirects is set to false, all responses with an HTTP status code from 300 to 399 is returned to the application.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p> |
| AllowInvalidCertificate : `Boolean`                | <p>Do not throw an exception on certificate error.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                               |
| AllowInvalidResponseContentTypeCharSet : `Boolean` | <p>Some Api's return faulty content-type charset header. This setting overrides the returned charset.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                            |
| ThrowExceptionOnErrorResponse : `Boolean`          | <p>Throw exception if return code of request is not successfull.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                 |
| AutomaticCookieHandling : `Boolean`                | <p>If set to false, cookies must be handled manually. Defaults to true.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                       |
| {% endtab %}                                       |                                                                                                                                                                                                      |

{% tab title="Result: Result" %}

| Name                 | Description                                                                                                                                                                                                                                                                                                                                                                             |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Body : `Object`      | <p>Contains the access token to a certain ServiceNow instance.<br>Example: <code>{ "access\_token": "6mq79vy2XwgVp-vnrijbn7\_JKfnbiebfjnube788743fYEiNltfjeOBbDTpMru664esGGvhJJxh2uJJ4EkDnKAkaA", "refresh\_token": "9zXaz\_7cfbe7fbcvF76bvce72aAHylz-IKJDb7fhbee7bfe74Pwh77vv0tz815ptH\_eFHr8zXzVA", "scope": "useraccount", "token\_type": "Bearer", "expires\_in": 1799 }</code></p> |
| StatusCode : `Int32` | <p>Statuscode of response<br>Example: <code>200</code></p>                                                                                                                                                                                                                                                                                                                              |
| {% endtab %}         |                                                                                                                                                                                                                                                                                                                                                                                         |

{% tab title="Changelog" %}

## Changelog

### \[1.1.0] - 2025-03-18

#### Changed

* Update packages: Newtonsoft.Json 12.0.3 -> 13.0.3 System.ComponentModel.Annotations 4.7.0 -> 5.0.0 System.Runtime.Caching 7.0.0 -> 9.0.3 coverlet.collector 3.1.2 -> 6.0.4 Microsoft.NET.Test.Sdk 16.6.1 -> 17.13.0 nunit 3.12.0 -> 4.3.2 NUnit3TestAdapter 3.17.0 -> 5.0.0

### \[1.0.0] - 2023-10-17

#### Changed

* Initial implementation
  {% endtab %}
  {% endtabs %}
