#### [Abblix\.Oidc\.Server](https://www.abblix.com/docs/api/abblix-oidc-server 'index')
### [Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.Interfaces](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.Interfaces')

## IDeviceAuthorizationStorage Interface

Defines the contract for a storage system responsible for persisting and retrieving
device authorization requests as defined in RFC 8628\.

```csharp
public interface IDeviceAuthorizationStorage
```

Derived  
↳ [DeviceAuthorizationStorage](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationStorage 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.DeviceAuthorizationStorage')
### Methods

## IDeviceAuthorizationStorage\.RemoveAsync\(string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.RemoveAsync(string)}

Removes a device authorization request from storage using its device code\.

```csharp
System.Threading.Tasks.Task RemoveAsync(string deviceCode);
```
#### Parameters

###### `deviceCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.RemoveAsync(string).deviceCode}

The device code identifier\.

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that completes when the request is removed\. Tidying the secondary user\-code index is
best\-effort and is logged rather than raised: it is not what the caller asked for, and a store
deciding otherwise must not become a fault where a grant error belongs\. Removing the request
itself is not guarded \- that IS what was asked, so a refusal there raises\.

## IDeviceAuthorizationStorage\.StoreAsync\(string, DeviceAuthorizationRequest, TimeSpan\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.StoreAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan)}

Stores a device authorization request with the specified device code\.

```csharp
System.Threading.Tasks.Task StoreAsync(string deviceCode, Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest request, System.TimeSpan expiresIn);
```
#### Parameters

###### `deviceCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.StoreAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan).deviceCode}

The unique device code identifier\.

###### `request` [DeviceAuthorizationRequest](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.DeviceAuthorizationRequest') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.StoreAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan).request}

The device authorization request to store\.

###### `expiresIn` [System\.TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan 'System\.TimeSpan') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.StoreAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan).expiresIn}

The duration after which the stored request will expire\.

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that completes when the request is stored\.

## IDeviceAuthorizationStorage\.TryGetByDeviceCodeAsync\(string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryGetByDeviceCodeAsync(string)}

Tries to retrieve a device authorization request by its device code\.
This is used by the client when polling the token endpoint\.

```csharp
System.Threading.Tasks.Task<Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest?> TryGetByDeviceCodeAsync(string deviceCode);
```
#### Parameters

###### `deviceCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryGetByDeviceCodeAsync(string).deviceCode}

The device code identifier\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[DeviceAuthorizationRequest](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.DeviceAuthorizationRequest')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A task that returns the device authorization request if found; otherwise, null\.

## IDeviceAuthorizationStorage\.TryGetByUserCodeAsync\(string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryGetByUserCodeAsync(string)}

Tries to retrieve a device authorization request by its user code\.
This is used during user verification to look up the pending request\.

```csharp
System.Threading.Tasks.Task<System.Nullable<(string DeviceCode,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest Request)>> TryGetByUserCodeAsync(string userCode);
```
#### Parameters

###### `userCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryGetByUserCodeAsync(string).userCode}

The user\-friendly verification code\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.valuetuple 'System\.ValueTuple')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[,](https://learn.microsoft.com/en-us/dotnet/api/system.valuetuple 'System\.ValueTuple')[DeviceAuthorizationRequest](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.DeviceAuthorizationRequest')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.valuetuple 'System\.ValueTuple')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A task that returns the device code and request if found; otherwise, null\.

## IDeviceAuthorizationStorage\.TryRemoveAsync\(string, string\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryRemoveAsync(string,string)}

Claims a device authorization request by its device code, deciding presence and removing it in one
protocol, so that a caller told it removed the request is the only caller that can be told so\. It
narrows that window rather than closing it; the returns block below says what a false covers\.

```csharp
System.Threading.Tasks.Task<bool> TryRemoveAsync(string deviceCode, string userCode);
```
#### Parameters

###### `deviceCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryRemoveAsync(string,string).deviceCode}

The device code identifier\.

###### `userCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.TryRemoveAsync(string,string).userCode}

The user code for cleaning up the secondary index mapping\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A task that returns true when this caller removed the request AND still held its own claim
afterwards\. False otherwise, which is wider than "somebody else got it": it also covers the
request not being there and a claim that expired while a store call was in flight \- the second
on one caller with nobody to lose to, and its outcome is the request gone with nobody able to be
told they took it\. An operator told a second REQUEST was the cause goes looking for one, and the
expiry case is exactly the one that never produces a second request\.

Removing the secondary user-code index is not part of that answer. It runs after the claim has
already decided, so a store that refuses it is logged and the answer stands. The entry left behind
expires on its own; what it still resolves to depends on the user code the caller passed, which
this method never checks against the record it removed.

## IDeviceAuthorizationStorage\.UpdateAsync\(string, DeviceAuthorizationRequest, TimeSpan\) Method {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.UpdateAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan)}

Updates an existing device authorization request in storage, refreshing its cache entry with the
caller\-supplied remaining lifetime\.

```csharp
System.Threading.Tasks.Task UpdateAsync(string deviceCode, Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest request, System.TimeSpan expiresIn);
```
#### Parameters

###### `deviceCode` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.UpdateAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan).deviceCode}

The device code identifier\.

###### `request` [DeviceAuthorizationRequest](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest 'Abblix\.Oidc\.Server\.Features\.DeviceAuthorization\.DeviceAuthorizationRequest') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.UpdateAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan).request}

The updated device authorization request\.

###### `expiresIn` [System\.TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan 'System\.TimeSpan') {#Abblix.Oidc.Server.Features.DeviceAuthorization.Interfaces.IDeviceAuthorizationStorage.UpdateAsync(string,Abblix.Oidc.Server.Features.DeviceAuthorization.DeviceAuthorizationRequest,System.TimeSpan).expiresIn}

The remaining lifetime to apply as the cache TTL\. The caller derives it from
            the request's fixed expiry \(RFC 8628 section 3\.2\) so that repeated polling cannot extend the code\.

#### Returns
[System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task')  
A task that completes when the request is updated\.
