DataStore - Sync error - UnauthorizedException
See original GitHub issueI receive this error:
DataStore - Sync error – "subscription failed Connection failed: {\"errors\":[{\"errorType\":\"UnauthorizedException\",\"message\":\"Permission denied\"}]}"
While I run this code:
Auth.currentCredentials() .then(d => console.log("data: ", d)) .catch(e => console.log("error: ", e));
before
this.init = DataStore.observe(Quiz).subscribe();
with this schema:
type Quiz
@model
@auth(
rules: [
{ allow: public, provider: iam, operations: [read] }
{ allow: owner }
]
) {
id: ID!
title: String!
seconds: Int!
currentQuestion: String
questionOrder: String
started: Boolean
questionTime: Int
view: Int
owner: String!
}
type Questions
@model
@auth(
rules: [
{ allow: public, provider: iam, operations: [read] }
{ allow: owner }
]
) {
id: ID!
image: String
youtube: String
question: String!
answerOne: String
answerOneCorrect: Boolean
answerTwo: String
answerTwoCorrect: Boolean
answerThree: String
answerThreeCorrect: Boolean
answerFour: String
answerFourCorrect: Boolean
quizID: String!
order: Int
public: Boolean
fromLibrary: Boolean
category: String
}
type QuestionsDB
@model
@auth(
rules: [
{ allow: public, provider: iam, operations: [read] }
{ allow: owner }
]
) {
id: ID!
image: String
youtube: String
question: String!
answerOne: String
answerOneCorrect: Boolean
answerTwo: String
answerTwoCorrect: Boolean
answerThree: String
answerThreeCorrect: Boolean
answerFour: String
answerFourCorrect: Boolean
relatedQuestion: String!
public: Boolean
category: String
language: String
}
type Subscribers @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
type: String!
score: Int!
quizID: String!
name: String!
}
type Responses @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
quiz: String!
subscriber: String!
question: String!
}
type Languages
@model
@auth(rules: [{ allow: public, provider: iam }])
@key(name: "ByCode", fields: ["type", "code"], queryField: "getLangByCode") {
id: ID!
type: String!
code: String!
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:29 (6 by maintainers)
Top Results From Across the Web
DataStore - subscriptionError, Connection failed
I want to use DataStore to only load the current user's data when the user is logged in. let uuID = ''; //...
Read more >Find Answers to AWS Questions about AWS Amplify Studio
If I change some data in the "content (datastore)" of Amplify Studio the data ... left empty from the console, it now shows...
Read more >DataStore - Other methods - Android - AWS Amplify Docs
Synchronization starts automatically whenever you run any DataStore operation ( query() , save() , delete() , observe() .) You can also explicitly begin...
Read more >Troubleshoot self-hosted integration runtime - Azure
Learn how to troubleshoot self-hosted integration runtime issues in Azure Data ... Copy one IR from datastore 1 to Azure Blob Storage ...
Read more >Troubleshooting Smart IT availability or stability issues
Important: During the start-up of Smart IT Server, it will sync these ... Data Store for Smart IT) with the Login ID and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not sure anymore 😔
Transferring this over per my conversation with @edwardfoyle.
I was able to reproduce this issue using the following simplified schema (and explicitly turning off subscription authorization on the model).
When I try to subscribe to changes on this model with DataStore as an unauthed user, I get the error:
"DataStore - Sync error subscription failed Connection failed: {"errors":{"errorType":"UnauthorizedException","message":"Permission denied”}}"
Here’s the schema:
App.js I’m using to reproduce the error:
I can also reproduce the UnauthorizedException error by attempting to subscribe without using DataStore:
Here’s the generated IAM policy (identical for authed and unauthed roles):
Dependency versions: