Skip to content

Commit

Permalink
Add documentation of TokenEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTTY committed Jul 26, 2024
1 parent 80e1121 commit a67c76f
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 23 deletions.
54 changes: 32 additions & 22 deletions docs/docs/api-reference/nordigen-api-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,50 @@ public NordigenClient(HttpClient httpClient, NordigenClientCredentials credentia
JsonWebTokenPair? jsonWebTokenPair = null)
```

### Arguments
### Parameters

##### `httpClient` - [HttpClient](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-8.0)

The `HttpClient` instance that should be used to send all requests made by the `NordigenClient`. You can adjust the `BaseAddress` of the `HttpClient` as needed, for details see: [Using a different Base Address](/docs/using-a-different-base-address).

##### `credentials` - NordigenClientCredentials

The credentials you get from the [GoCardless Bank Account Data portal](https://bankaccountdata.gocardless.com/login/) (User secrets).

##### `jsonWebTokenPair` - JsonWebTokenPair?

An optional `JsonWebTokenPair` to reuse from an preceding successful authentication. These may for instance be retrieved from your database.

## Properties

```csharp
public JsonWebTokenPair? JsonWebTokenPair
```
#### `JsonWebTokenPair` - JsonWebTokenPair?

```csharp
public ITokenEndpoint TokenEndpoint
```
The JWT pair consisting of access and refresh token used to authenticate with the GoCardless API. This property can be used to set the token pair that is used when retrieving a new access/refresh token through the `TokenEndpoint`.

```csharp
public IInstitutionsEndpoint InstitutionsEndpoint
```
#### `TokenEndpoint` - ITokenEndpoint

```csharp
public IAgreementsEndpoint AgreementsEndpoint
```
Provides support for the API operations of the tokens endpoint.

```csharp
public IRequisitionsEndpoint RequisitionsEndpoint
```
#### `InstitutionsEndpoint` - IInstitutionsEndpoint

```csharp
public IAccountsEndpoint AccountsEndpoint
```
Provides support for the API operations of the institutions endpoint.

```csharp
public event EventHandler<TokenPairUpdatedEventArgs>? TokenPairUpdated
```
#### `AgreementsEndpoint` - IAgreementsEndpoint

Provides support for the API operations of the agreements endpoint.

#### `RequisitionsEndpoint` - IRequisitionsEndpoint

Provides support for the API operations of the requisitions endpoint.

#### `AccountsEndpoint` - IAccountsEndpoint

Provides support for the API operations of the accounts endpoint.

## Events

#### `TokenPairUpdated` - EventHandler\<TokenPairUpdatedEventArgs\>?

Occurs whenever the `JsonWebTokenPair` property is successfully updated.
When the token is manually updated to be null, this event will not be raised.
For more information see [Handling Authentication Tokens](/docs/handling-authentication-tokens).
53 changes: 53 additions & 0 deletions docs/docs/api-reference/token-endpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: TokenEndpoint
---

The `TokenEndpoint` class provides support for the API operations of the tokens endpoint.

## Methods

### `GetTokenPair`

Obtain a new JWT token pair from the Nordigen API.

```csharp
public async Task<NordigenApiResponse<JsonWebTokenPair, BasicResponse>>
GetTokenPair(CancellationToken cancellationToken = default)
```

#### Parameters

##### `cancellationToken` - [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-8.0)

Optional token to signal cancellation of the operation.

#### Returns

`Task<NordigenApiResponse<JsonWebTokenPair, BasicResponse>>`

A `NordigenApiResponse` containing the obtained `JsonWebTokenPair` if the request was successful.

### `RefreshAccessToken`

Refresh the given JWT access token using a valid refresh token.

```csharp
public async Task<NordigenApiResponse<JsonWebAccessToken, BasicResponse>>
RefreshAccessToken(JsonWebToken refreshToken, CancellationToken cancellationToken = default)
```

#### Parameters

##### `refreshToken` - [JsonWebToken](https://learn.microsoft.com/en-us/dotnet/api/microsoft.identitymodel.jsonwebtokens.jsonwebtoken?view=msal-web-dotnet-latest)

A valid refresh token that was previously obtained.

##### `cancellationToken` - [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-8.0)

Optional token to signal cancellation of the operation.

#### Returns

`Task<NordigenApiResponse<JsonWebAccessToken, BasicResponse>>`

A `NordigenApiResponse` containing the refreshed `JsonWebAccessToken` if the request was successful.
5 changes: 5 additions & 0 deletions docs/docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Testing
---

TODO
6 changes: 5 additions & 1 deletion docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ const sidebars: SidebarsConfig = {
"quickstart-guide",
"handling-authentication-tokens",
"using-a-different-base-address",
"testing",
{
type: "category",
label: "API Reference",
items: ["api-reference/nordigen-api-client"],
items: [
"api-reference/nordigen-api-client",
"api-reference/token-endpoint",
],
},
],
};
Expand Down

0 comments on commit a67c76f

Please sign in to comment.