
I've implemented the oAuth Login with Google successfully and everything is working fine. Now when I tested all the error possibilities, I go something weird.
When the user starts the oAuth, it takes the user to the oAuth webpage. If the user presses back or gets back without completing the whole processes, then the app throws a java.lang.IllegalStateException with message User cancelled login . It occurs whenever user didn't complete the whole step. But when user completes all steps, the app works fine and there is no error.
I tried to catch the Exception, but couldn't. This triggers a Fatal Exception and crashes the app.
Here is the code I'm using -
private suspend fun loginWithGoogle() {
val account = Account(userModelRepository.client)
withContext(Dispatchers.IO) {
try {
val createSessionDeferred = async {
val result = account.createOAuth2Session(
activity = this@LoginHome,
provider = "google"
)
}
// Wait for createOAuth2Session to complete
createSessionDeferred.await()
// check session method here
userDetailsViewModel.getSession()
} catch (e: AppwriteException) {
e.printStackTrace()
} catch (e: Exception) {
e.printStackTrace()
} catch (e: IllegalStateException) {
e.printStackTrace()
}
}
}
Recommended threads
- CORS errors with storage bucket
I have a javascript file in the storage bucket and I used the view endpoint in an `src` attribute of a `<script>` tag. But I am getting the `net::ERR_BLOCKED_BY...
- Oauth2-Error 400Invalid `success` param:...
My code: > await new Account(client).createOAuth2Session(OAuthProvider.Google, 'https://www.mydomain.online/home', 'https://www.mydomain.online'); I ha...
- Issue with Appwrite Function Execution –...
Hi all, I'm encountering an issue when calling an Appwrite function from my Flutter app. **Environment:** ```Flutter SDK: 3.27.3 Appwrite Flutter SDK: 16.1.0```...
