Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using googleApi #15

Closed
matthewkooshad opened this issue Sep 4, 2018 · 2 comments
Closed

Error using googleApi #15

matthewkooshad opened this issue Sep 4, 2018 · 2 comments

Comments

@matthewkooshad
Copy link

final simpleAuth.GoogleApi googleApi = new simpleAuth.GoogleApi("google",
      "992461286651-k3tsbcreniknqptanrugsetiimt0lkvo.apps.googleusercontent.com",
      clientSecret: "avrYAIxweNZwcHpsBlIzTp04",
      scopes: [
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/userinfo.profile"
      ]);

final googleLoginButton = Padding(
      padding: EdgeInsets.symmetric(vertical: 16.0),
      child: Material(
        borderRadius: BorderRadius.circular(30.0),
        shadowColor: Colors.lightBlueAccent.shade100,
        elevation: 5.0,
        child: MaterialButton(
          minWidth: 200.0,
          height: 42.0,
          onPressed: () async {
              try {
                var user = await googleApi.getUserProfile();
                showMessage("${user.name} logged in");
              } catch (e) {
                showError(e);
              }
            },
          color: Colors.lightBlueAccent,
          child: Text('Log In Using Google', style: TextStyle(color: Colors.white)),
        ),
      ),
    );

i also have set in testapp\android\app\src\main\AndroidManifest.xml , the same key:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testapp">

    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="app1"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <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.992461286651-k3tsbcreniknqptanrugsetiimt0lkvo" />
            </intent-filter>
        </activity>
    </application>
</manifest>

here's the error i get when i try the button:

type 'int' is not a subtype of type 'String'

also, if i try to simply change 992461286651-k3tsbcreniknqptanrugsetiimt0lkvo to my google android project's key, then i get this error instead:

Invalid argument(s): The source must not be null

what's going on with error when trying to use the test project and what might i be doing wrong in my google android project, such that when using its key, i get a different error?

thanks,
my google project looks like this:
image

image

@Clancey Clancey closed this as completed in bdd7623 Sep 4, 2018
@matthewkooshad
Copy link
Author

final simpleAuth.GoogleApi googleApi = new simpleAuth.GoogleApi("google",
"992461286651-k3tsbcreniknqptanrugsetiimt0lkvo.apps.googleusercontent.com",
"http://localhost",
clientSecret: "avrYAIxweNZwcHpsBlIzTp04",
scopes: [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
]);

is this how i should update it with the latest change? i don't know what to use for the redirecturl.

and, i don't to the choose an acct screen with the latest..:
image

@Clancey
Copy link
Owner

Clancey commented Sep 4, 2018

So, this just reminded me. Redirect is not required for Google. I auto create the redirect for you. I am adding back the default. However your error is not related. That means your device/emulator has internet issues. Go to chrome and verify that Google works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants