# MoveAuthState

Returns the current MOVE SDK Authentication State.

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

```kotlin
enum class MoveAuthState {
    UNKNOWN,
    VALID,
    INVALID,
    @Deprecated("Do not use this state in your code")
    EXPIRED(MoveAuth)
}
```

{% endtab %}

{% tab title="iOS" %}

```swift
enum MoveAuthState {
    case unknown
    
    @available(*, deprecated, message: "Token expiry was removed.")
    case expired
    
    case valid
    
    case invalid
}
```

{% endtab %}

{% tab title="React Native" %}

```javascript
export type AuthState = 'UNKNOWN' | 'VALID' | 'INVALID' | 'EXPIRED';
```

{% endtab %}

{% tab title="Flutter" %}

```dart
import 'package:movesdk/io/dolphin/move/move_auth_state.dart';
```

```dart
enum MoveAuthState {
  unknown,
  
  @Deprecated('obsolete')
  expired,
  
  invalid,
  
  valid,
}
```

{% endtab %}
{% endtabs %}

| MoveAuthState                                                                   |                                                                                                                                                        |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| expired([MoveAuth](https://docs.movesdk.com/move-platform/sdk/models/moveauth)) | Latest [MoveAuth](https://docs.movesdk.com/move-platform/sdk/models/moveauth) expired and the MOVE SDK can't refresh it. **Deprecated in SDK v2.6.7**. |
| valid                                                                           | Authentication is valid.                                                                                                                               |
| invalid                                                                         | Authentication is invalid. e.g. User has logged in on multiple devices. **New since SDK v2.4**                                                         |
| unknown                                                                         | MOVE SDK auth state is pending, and will be updated when the server is contacted. The app should ignore this state.                                    |

{% hint style="warning" %}
**If the MoveAuthState is invalid the MOVE backend no longer accepts MOVE SDK requests from this host app.**
{% endhint %}

### Authentication updates and invalidation

[MoveAuth](https://docs.movesdk.com/move-platform/sdk/models/moveauth) 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.

In case the MOVE SDK fails to refresh authentication, because of a conflicting login on another device, or because the user was blocked on the backend, it will trigger `MoveAuthState.invalid`. The host app is expected to logout the user and call`shutdown(force: true)`([Android](https://docs.movesdk.com/move-platform/api-interface/android/services#shutdown-sdk) / [iOS](https://docs.movesdk.com/move-platform/api-interface/ios/setup#shutdown)).

{% hint style="warning" %}

#### Authentication Updates

The host app is responsible for monitoring `MoveAuthState` updates and handling its state updates by:

* `.invalid`: The MOVE SDK has invalidated its internal user token at once. e.g. User has logged in on multiple devices. If necessary the host app has to register the user again (see [register - MOVE Admin API](https://docs.movesdk.com/move-platform/backend/move-backend/move-admin-api#gettingstartedwiththedolphinmovetimelineservice-authentication-1)).
  {% endhint %}

| MoveAuthState related APIs                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |                                                                                                                          |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `authStateUpdateListener` ([Android](https://docs.movesdk.com/move-platform/api-interface/android/initialization#dolphinsdk.builderv1.1-initializationinitializationlistener-1) / [iOS](https://docs.movesdk.com/move-platform/api-interface/ios/setup#set-sdk-auth-state-listener) / [React](https://docs.movesdk.com/move-platform/api-interface/react-native/services#set-sdk-auth-state-listener) / [Flutter](https://docs.movesdk.com/move-platform/sdk/listeners-callbacks#flutter-1)) | Block to be invoked every time [MoveAuthState](https://docs.movesdk.com/move-platform/sdk/models/moveauthstate) changes. |
