Clancey / simple_auth

The Simplest way to Authenticate in Flutter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redirect to app instead of showing google.com

cahyowhy opened this issue · comments

i tried to auth using SimpleAuth.GoogleApi, after auth success it will redirect to google.com page if i close the page it throw cancelexception error.

this is my code

 onLoginGAuth() async {
    try {
      var googleApi = SimpleAuth.GoogleApi(
          "google",
          "299691635903-lshq4jq9v73qpel2vq60bqd250a9j35j.apps.googleusercontent.com",
          "urn:ietf:wg:oauth:2.0:oob",
          clientSecret: "LwndzxyjJR5BEGcNA1soA6Ee",
          scopes: [
            "https://www.googleapis.com/auth/userinfo.email",
            "https://www.googleapis.com/auth/userinfo.profile"
          ]);

      var userInfo = await googleApi.authenticate();
      print(userInfo);
    } catch (e) {
      print(e.toString());
    }
  }

this is my manifest file

<activity android:name="clancey.simpleauth.simpleauthflutter.SimpleAuthCallbackActivity" >
            <intent-filter android:label="simple_auth">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="id.getngo.mobile" />
            </intent-filter>
        </activity>

thanks

@cahyowhy hello I'm currently having the same problem, did you ever figure out how to fix this?

@pamelakuang currently does'nt use this anymore..
i use this..
google_sign_in: ^4.5.1

Same problem here :(

commented

Spent some time and found redirectUrl is broken unless you set useEmbeddedBrowser to true. It by defaults generating "com.googleusercontent.apps.${this.clientId}:/oauthredirect" as the redirect URI.
so you have to update AndroidManifest.xml and set android:scheme to your app client id

        <activity android:name="clancey.simpleauth.simpleauthflutter.SimpleAuthCallbackActivity" >
            <intent-filter android:label="simple_auth">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="com.googleusercontent.apps.299691635903-lshq4jq9v73qpel2vq60bqd250a9j35j" />
            </intent-filter>
        </activity>