# MoveAuthState

Returns the current SDK Authentication State.

{% tabs %}
{% tab title="Android" %}

```kotlin
enum class MoveAuthState {
    UNKNOWN,
    VALID(MoveAuth)
    EXPIRED(MoveAuth)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
enum MoveAuthState {
    case unknown
    case expired
    case valid(MoveAuth)
}
```

{% endtab %}

{% tab title="React Native" %}

```javascript
export type AuthState = 'unknown' | 'valid' | 'expired';
```

{% endtab %}
{% endtabs %}

| MoveAuthState                                                           |                                                                                                             |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| expired([MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md)) | Latest [MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md) expired and the SDK can't refresh it. |
| valid([MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md))   | Authentication is valid. Latest [MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md) provided.    |
| unknown                                                                 | The SDK authorization state when SDK is uninitialized.                                                      |

### Authentication updates and expiry

[MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md) is session-based, hence it expires and requires to be renewed. For simplicity, the MOVE SDK handles refreshing the token for the host app whenever it expires and passes the new MoveAuth when updated via `authStateChangeListener` (Android / [iOS](/move-platform/move-sdk-1.x/sdk/api-interface/ios/services.md#set-sdk-auth-state-listener)) API callback.

In case the SDK fails to refresh authentication, it will trigger [MoveAuthState](/move-platform/move-sdk-1.x/sdk/models/moveauthstate.md)`.expired`. The host app is expected to fetch a new token with the product's API Key and then call `update(auth: MoveAuth)`([Android](/move-platform/move-sdk-1.x/sdk/api-interface/android-1/android.md#update-authentication) / [iOS](/move-platform/move-sdk-1.x/sdk/api-interface/ios/services.md#update-authentication)) API.

{% hint style="warning" %}

#### Authentication Updates

The host app is responsible for monitoring [MoveAuthState](/move-platform/move-sdk-1.x/sdk/models/moveauthstate.md) updates and handling its state updates by:

* `.expired`: Requesting new Auth using the product's API Key and then passing it to the SDK using [`update(auth: MoveAuth)`](/move-platform/move-sdk-1.x/sdk/api-interface/ios/services.md#update-authentication) API.
* `.valid(MoveAuth)`: Persisting the new [MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md) provided by the SDK, so the app can pass this new [MoveAuth](/move-platform/move-sdk-1.x/sdk/models/moveauth.md) next time it is initializing the SDK.
  {% endhint %}

| MoveAuthState related APIs                                                                                                             |                                                                                                                  |
| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `getSDKAuthState` (Android / [iOS](/move-platform/move-sdk-1.x/sdk/api-interface/ios/services.md#get-sdk-auth-state))                  | Gets the current [MoveAuthState](/move-platform/move-sdk-1.x/sdk/models/moveauth.md).                            |
| setSDKAuthUpdatesListener (Android / [iOS](/move-platform/move-sdk-1.x/sdk/api-interface/ios/services.md#set-sdk-auth-state-listener)) | Block to be invoked every time [MoveAuthState](/move-platform/move-sdk-1.x/sdk/models/moveauthstate.md) changes. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.movesdk.com/move-platform/move-sdk-1.x/sdk/models/moveauthstate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
