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

Amplify Configure Not Working #291

Closed
markpearl opened this issue Jan 4, 2021 · 2 comments
Closed

Amplify Configure Not Working #291

markpearl opened this issue Jan 4, 2021 · 2 comments
Labels
core Issues related to the Amplify Core Plugin

Comments

@markpearl
Copy link

markpearl commented Jan 4, 2021

Amplify Configure Method Not working
I've setup Amplify and created basic authentication with Facebook and Signup. In addition, I've setup some basline data models in the Amplify Admin UI, which in turn created the GraphQL api configuration. So the two services I have now are the auth and api.

I've been following this tutorial to setup authentication via amplify:
https://aws.amazon.com/getting-started/hands-on/build-flutter-app-amplify/module-two/

I ran the following steps:

  1. Amplify Init: -Create a new username on my aws console and provided the Access Key ID and Secret Key
  2. Amplify Pull: I did not run amplify configure because I already have an existing backend environment setup, so I just ran the amplify pull command for the existing staging environment. This created the amplify folder under lib and the amplifyconfiguration.dart.

When I run main.dart I receive the following:

I/flutter ( 9867): No implementation found for method configure on channel com.amazonaws.amplify/core
I/flutter ( 9867): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
I/flutter ( 9867):
I/flutter ( 9867): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
I/flutter ( 9867): #2 MethodChannelAmplifyCore.configure (package:amplify_core_plugin_interface/method_channel_amplify.dart:25:21)
I/flutter ( 9867): #3 Amplify.configure (package:amplify_core/amplify_core.dart:86:35)
I/flutter ( 9867): #4 _AynoAppState._configureAmplify (package:ayno_app/main.dart:38:22)
I/flutter ( 9867): #5 _AynoAppState.initState (package:ayno_app/main.dart:31:5)
I/flutter ( 9867): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58)
I/flutter ( 9867): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5)
I/flutter ( 9867): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14)
I/flutter ( 9867): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:3327:18)
I/flutter ( 9867): #10 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1252:16)
I/flutter ( 9867): #11 RenderObjectToWidgetElement.mount (p

To Reproduce
Steps to reproduce the behavior: Don't have full project uploaded. But can provide if this is not an easy fix.

Expected behavior
The expected behavior is amplify configure works properly and prints out the following message:
print('Successfully configured Amplify 🎉');

Screenshots
If applicable, add screenshots to help explain your problem.

Platform
Amplify Flutter current supports iOS and Android. This issue is reproducible in (check all that apply):
[x] Android
[x] iOS

Smartphone (please complete the following information):

  • Device: Pixel 4_XL_API_27
  • OS: [e.g. iOS8.1] Android
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22] Android API 28 (Build Target)

main.dart:
`//import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_core/amplify_core.dart';
import 'package:flutter/material.dart';
import 'package:ayno_app/theme/style.dart';
import 'package:ayno_app/bloc/bloc-prov-tree.dart';
import 'package:ayno_app/bloc/bloc-prov.dart';
import 'package:ayno_app/blocs/blocs.dart';
import 'package:ayno_app/auth_service.dart';
import 'package:ayno_app/screens/signupscreen_start/signupscreen_start.dart';
import 'package:ayno_app/verification.dart';
import 'package:ayno_app/screens/splash/splashscreen.dart';
import 'amplifyconfiguration.dart';
import 'package:stack_trace/stack_trace.dart';

void main() {
runApp(AynoApp());
}

class AynoApp extends StatefulWidget {
@OverRide
State createState() => _AynoAppState();
}

class _AynoAppState extends State {
final _authService = AuthService();
final _amplify = Amplify();

@OverRide
void initState() {
super.initState();
_configureAmplify();
_authService.showLogin();
}

void _configureAmplify() async {
//_amplify.addPlugin(authPlugins: [AmplifyAuthCognito()]);
try {
await _amplify.configure(amplifyconfig);
print('Successfully configured Amplify 🎉');
} catch (e, stack) {
print(e.message);
print(stack);
//print('Could not configure Amplify ☠️');
}
}

@OverRide
Widget build(BuildContext context) {
return BlocProviderTree(
blocProviders: [
BlocProvider(bloc: AuthBloc()),
BlocProvider(bloc: PrefBloc()),
],
child: MaterialApp(
theme: appTheme(),
home: StreamBuilder(
stream: _authService.authStateController.stream,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Navigator(
pages: [
MaterialPage(child: SplashScreen()),
if (snapshot.data.authFlowStatus ==
AuthFlowStatus.login)
MaterialPage(child: SplashScreen()),
if (snapshot.data.authFlowStatus ==
AuthFlowStatus.signUp)
MaterialPage(
child: SignUpPageStart(
shouldShowLogin: _authService.showLogin)),
if (snapshot.data.authFlowStatus ==
AuthFlowStatus.verification)
MaterialPage(
child: VerificationPage(
didProvideVerificationCode:
_authService.verifyCode))
],
onPopPage: (route, result) => route.didPop(result),
);
} else {
return Container(
alignment: Alignment.center,
child: CircularProgressIndicator(),
);
}
}
)
)
);
}
}
pubspec.yaml:name: ayno_app
description: Ayno flutter application containing an app designed to revolutionize car advertising.

version: 1.0.0+1

environment:
sdk: ">=2.7.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
http: ^0.12.0
flutter_screenutil: ^0.5.3
intl: ^0.15.7
flutter_facebook_login:
git: https://github.com/lequanghiep74/flutter_facebook_login
mvc_pattern: ^3.4.3
amplify_core: '<1.0.0'
amplify_auth_cognito: '<1.0.0'
splashscreen: ^1.2.0
google_fonts: ^1.1.1
cupertino_icons: ^0.1.3
esys_flutter_share: ^1.0.2
shared_preferences: ^0.5.6+1s
flutter_staggered_grid_view: ^0.3.2

dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.8.1

flutter_icons:
android: true
ios: true
image_path: "assets/images/ayno_logo_blue-circle.png"

flutter:
uses-material-design: true

assets:

  • assets/images/
    `

amplifyconfiguration.dart:
const amplifyconfig = ''' { "UserAgent": "aws-amplify-cli/2.0", "Version": "1.0", "api": { "plugins": { "awsAPIPlugin": { "aynoapp": { "endpointType": "GraphQL", "endpoint": "https://co7t4clgwbaermpsi7c74nnboi.appsync-api.ca-central-1.amazonaws.com/graphql", "region": "ca-central-1", "authorizationType": "API_KEY", "apiKey": "" } } } }, "auth": { "plugins": { "awsCognitoAuthPlugin": { "UserAgent": "aws-amplify-cli/0.1.0", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CredentialsProvider": { "CognitoIdentity": { "Default": { "PoolId": "ca-central-1:7056ee80-a4cd-47bc-9714-c41c6f920baf", "Region": "ca-central-1" } } }, "CognitoUserPool": { "Default": { "PoolId": "ca-central-1_pDIKRnzqa", "AppClientId": "", "Region": "ca-central-1" "AppClientSecret": "", } }, "Auth": { "Default": { "OAuth": { "WebDomain": "xocakm2yuysu-staging.auth.ca-central-1.amazoncognito.com", "AppClientId": "", "AppClientSecret": "", "SignInRedirectURI": "https://xocakm2yuysu.auth.ca-central-1.amazoncognito.com/", "SignOutRedirectURI": "https://xocakm2yuysu.auth.ca-central-1.amazoncognito.com/", "Scopes": [ "phone", "email", "openid", "profile", "aws.cognito.signin.user.admin" ] }, "authenticationFlowType": "USER_SRP_AUTH" } }, "AppSync": { "Default": { "ApiUrl": "https://co7t4clgwbaermpsi7c74nnboi.appsync-api.ca-central-1.amazonaws.com/graphql", "Region": "ca-central-1", "AuthMode": "API_KEY", "ApiKey": "", "ClientDatabasePrefix": "aynoapp_API_KEY" }, "aynoapp_AWS_IAM": { "ApiUrl": "https://co7t4clgwbaermpsi7c74nnboi.appsync-api.ca-central-1.amazonaws.com/graphql", "Region": "ca-central-1", "AuthMode": "AWS_IAM", "ClientDatabasePrefix": "aynoapp_AWS_IAM" } } } } } }''';

@haverchuck haverchuck added the core Issues related to the Amplify Core Plugin label Jan 7, 2021
@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 20, 2021

Hey @markpearl apologies for the delayed response to your issue here - were you able to resolve your issue in the end?

Within your AmplifyConfiguration file it looks like you have keys for API Plugin but in your initialization dart code, you only added the AuthCognito plugin. Could you try adding our API plugin as well and see if that fixes your issue?

@markpearl
Copy link
Author

markpearl commented Jan 20, 2021 via email

@fjnoyp fjnoyp closed this as completed Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues related to the Amplify Core Plugin
Projects
None yet
Development

No branches or pull requests

3 participants