Skip to content
Back

google Auth in Android not working

  • 3
  • Android
  • Auth
  • Cloud
INAKA
26 Dec, 2024, 05:54

i am adding "login with google" button in my android app, i have completely setup the google auth in appwrite and google cloud console too. heres what i have done to setup the google auth yet: -enabled google auth in "auth" section in appwrite.

-created Oauth client id on google cloud console with the redirect URL provided by appwrite and copy pasted the "app id" and "app secret" from this OAuth Client id to Google OAuth2 Settings in appwrite.

-Added the below codeto my manifest file for callback:

TypeScript
<activity
            android:name="io.appwrite.views.CallbackActivity"
            android:exported="true">
            <intent-filter android:label="android_web_auth">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="auth"
                    android:scheme="appwrite-callback-67699acf002ecc80c89f"/>
            </intent-filter>
        </activity>

Below is my code for google auth in my app:

TypeScript
suspend fun googleAuth(activity: ComponentActivity) {
        val account = Account(client)

        try {
            // Launch OAuth2 session creation
            account.createOAuth2Session(
                provider = OAuthProvider.GOOGLE,
                activity = activity
            )
            // Log success
            Log.d(TAG, "OAuth2 session created successfully with Google.")
            // Fetch session to confirm
            getSession()
        } catch (e: AppwriteException) {
            Log.e(TAG, "Error creating OAuth2 session with Google: ${e.message}", e)
            error.postValue(e)
        } catch (e: Exception) {
            Log.e(TAG, "Unexpected error during OAuth2 session creation: ${e.message}", e)
            error.postValue(AppwriteException("Unexpected error occurred: ${e.message}"))
        }
    }
TL;DR
Developers are facing issues with Google Auth in Android applications after recent updates, causing OAuth2 functionality to stop working. The problem seems to be common but no solution has been found yet. The issue has been reported on various threads. The error is occurring in the smartphone browser, making debugging difficult. One developer shared their setup process for Google Auth, including enabling it in Appwrite and creating OAuth client ID in Google Cloud Console. The code snippet provided in the manifest file for the callback is also mentioned, along with the function used for Google Auth in the app's code.
INAKA
26 Dec, 2024, 05:54

google Auth in Android not working

INAKA
26 Dec, 2024, 05:56

here's the video of the error thats occuring

INAKA
26 Dec, 2024, 05:56
INAKA
26 Dec, 2024, 05:56

what am i doing wrong?

INAKA
26 Dec, 2024, 06:36

and also , other things in my project are working, like fetching documents from database, etc

INAKA
26 Dec, 2024, 09:01

guys help pls?

Seroga88i
26 Dec, 2024, 10:20

@INAKA It looks like this is a common problem after an update or something. We see the problem in these threads too: https://discord.com/channels/564160730845151244/1320707153840963704/1321716319841812562 and here too: https://discord.com/channels/564160730845151244/1321088199971442748/1321124965038428231

Unfortunately no idea what happened 😕

INAKA
26 Dec, 2024, 10:53

yaaa, this seems like a common problem, but when will it get resolved?

Seroga88i
26 Dec, 2024, 10:55

@INAKA this is a good question. I am a little bit confused, I did not change my application code and out of sudden the oauth2 functionality is not working 🤷‍♂️

Seroga88i
26 Dec, 2024, 10:56

I tried to debug the problem, but the response is occuring the browser of the smartphone this is kinda hard to debug it in device browser 😕

patialashahi
26 Dec, 2024, 11:14

I am also facing the same.

Seroga88i
26 Dec, 2024, 11:16

try to upvote the first post in this thread: https://discord.com/channels/564160730845151244/1321717751798038600/1321717751798038600 Maybe we get attention that way

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more