Clancey / simple_auth

The Simplest way to Authenticate in Flutter
MIT License
352 stars 108 forks source link

redirect to app instead of showing google.com #136

Open cahyowhy opened 4 years ago

cahyowhy commented 4 years ago

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

pamelakuang commented 4 years ago

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

cahyowhy commented 4 years ago

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

SwannLV commented 4 years ago

Same problem here :(

eGust commented 4 years ago

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>