-
Notifications
You must be signed in to change notification settings - Fork 249
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
Not Authorized to access createStashItem on type StashItem #2533
Comments
Hi @tmageebtr thanks for opening this issue. When you execute:
Have you signed in a user? |
Yes. Using amplify_authenticator. `class MyApp extends StatelessWidget { // This widget is the root of your application. |
Could you provide your |
Here it is. looking at this I'm wondering if the poolIDs are correct, though I am not sure how to verify. I have not modified this file, it is as generated by cli.
|
I updated my code to reflect what is in your example code and create the graphql document by hand rather than use ModelMutations.create. This appears to correctly create the item in the backend. ` final stash = StashItem(name: name);
|
Oh in that case, I think this issue is caused my the same reason as #2492 . |
#2492 . seems to have been the reason. Only affects creates, updates work fine. Closing Issue. |
I am getting an error when trying to create a record using graphql. Android 33 and Web. Using AppSync console create is successful.
dependencies:
flutter:
sdk: flutter
amplify_flutter: ^1.0.0-next.2
amplify_authenticator: ^1.0.0-next.1+3
amplify_auth_cognito: ^1.0.0-next.2+1
amplify_api: ^1.0.0-next.2+1
amplify_datastore: ^1.0.0-next.2
errors: [GraphQLResponseError{
"message": "Not Authorized to access createStashItem on type StashItem",
"locations": [
{
"line": 1,
"column": 102
}
],
"path": [
"createStashItem"
]
}]
model
type StashItem @aws_cognito_user_pools @model(timestamps:{createdAt: "createdOn", updatedAt: "updatedOn"}) @auth(rules: [ {allow: owner, ownerField: "userid",operations: [create, update, delete, read]}, { allow: public, operations: [create, read]}, ]) { id: ID! @primaryKey userid: String name: String }
code calling create
Future<void> createStashI(name) async { try { final stash = StashItem(name: name); final request = ModelMutations.create(stash, authorizationMode: APIAuthorizationType.userPools); debugPrint("request: $request"); final response = await Amplify.API.mutate(request: request).response; debugPrint("request: $response"); final createdStashItem = response.data; if (createdStashItem == null) { safePrint('errors: ${response.errors}'); return; } safePrint('Mutation result: ${createdStashItem.name}'); } on ApiException catch (e) { safePrint('Mutation failed: $e'); } }
Amplify configure code
Future<void> _configureAmplify() async { if (!Amplify.isConfigured) { try { await Amplify.addPlugins([ AmplifyAuthCognito( credentialStorage: AmplifySecureStorage( config: AmplifySecureStorageConfig( scope: 'api', macOSOptions: MacOSSecureStorageOptions(useDataProtection: false), ), ), ), AmplifyAPI(modelProvider: ModelProvider.instance) ]); await Amplify.configure(amplifyconfig); } on Exception catch (e) { safePrint('An error occurred while configuring Amplify: $e'); } } }
The text was updated successfully, but these errors were encountered: