Integrating AppWrite Google Auth in Flutter

This article will help you understand how to integrate the appwrite google auth in flutter.

First of all go to appwrite and create the project. And go to the the google cloud console and configure the project for OAuth Credentials.

While setting up the oauth, remember you only need web client and secret for appwrite google auth to configure. Grab the client ID and Client Secret from the console.

Note that the redirect urls should be configured properly. If you are self hosting the it you need to have botth https and http protocol to authorized origins, else will give error to brust your head

And the setup is done, we will just into coding it.

This the code you need, you put in AndroidManifest.xml file :

<activity android:exported="true" android:name="com.linusu.flutter_web_auth_2.CallbackActivity" >
  <intent-filter android:label="flutter_web_auth_2">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="appwrite-callback-project_id" />
  </intent-filter>
</activity>
            Client client = Client()
                                    .setProject('project id')
                                    .setSelfSigned(status: true);
                                // Your Appwrite Project ID
                                Account account = Account(client);
                                await account.createOAuth2Session(
                                  provider: OAuthProvider.google,
                                  scopes: [], // optional
                                );

                                final user = await account.get();
Updated on