element-hq / element-hq/element-android

App crash with code=M_UNKNOWN_TOKEN, message=Invalid access token passed[SDK]

Open
#8,723 0 comments 0 reactions 0 assignees View on GitHub
matrix-sdk
Dominant language
Kotlin
Stars
3.7k
Forks
917
PR merge metrics
No merged PRs in 30d

Description

### Description

I've created a matrix session with credentials like below :-
```
val credential = Credentials(
userId = userId,
accessToken = accessToken,
homeServer = homeServer,
refreshToken = null, deviceId = deviceId
)
currentSession = matrix.authenticationService().createSessionFromSso(
homeServerConnectionConfig, credential
)
```

here I am passing refresh token as `null` as i want my access token to not expire we haven't set any expiration time or session lifetime so my access token should be valid until my session is live.

Now when I try to open app after 1-2 days of login it start giving me below error :-
```
java.lang.RuntimeException: MatrixError(code=M_UNKNOWN_TOKEN, message=Invalid access token passed., consentUri=null, limitType=null, adminUri=null, retryAfterMillis=null, isSoftLogout=false, newLookupPepper=null, session=null, completedStages=null, flows=null, params=null)
```

this makes my app crash.

I am not sure how does my token gets invalid or expire as I don't have any method which does this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.