Skip to content

Commit ef584f3

Browse files
edit the public iam example, adding allowGuestAss to Amplify.configure instead of json file
1 parent 2d5be52 commit ef584f3

File tree

1 file changed

+18
-19
lines changed
  • src/pages/gen2/build-a-backend/data/customize-authz/public-data-access

1 file changed

+18
-19
lines changed

src/pages/gen2/build-a-backend/data/customize-authz/public-data-access/index.mdx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,26 @@ const schema = a.schema({
6464
In your application, you can perform CRUD operations against the model using `client.models.<ModelName>` with the `iam` auth mode.
6565

6666
<Callout info>
67-
In the Amplify Library's client configuration file (`amplifyconfiguration.json`) set `allowGuestAccess` to `true`. This lets the Amplify Library use the unauthenticated role from your Cognito identity pool when your user isn't logged in.
67+
In the Amplify Library's resource configuration set `allowGuestAccess` to `true`. This lets the Amplify Library use the unauthenticated role from your Cognito identity pool when your user isn't logged in.
6868

69-
<Accordion title="amplifyconfiguration.json">
69+
<Accordion title="">
7070
```json
71-
{
72-
"Auth": {
73-
"Cognito": {
74-
"userPoolId": "YOUR_USER_POOL_ID",
75-
"userPoolClientId": "YOUR_USER_POOL_CLIENT_ID",
76-
"identityPoolId": "YOUR_IDENTITY_POOL_ID",
77-
"allowGuestAccess": true
78-
},
79-
},
80-
"API": {
81-
"GraphQL": {
82-
"endpoint": "YOUR_API_ENDPOINT",
83-
"region": "YOUR_API_REGION",
84-
"defaultAuthMode": "YOUR_DEFAULT_AUTHORIZATION_MODE",
85-
},
86-
},
87-
}
71+
import { Amplify } from "aws-amplify";
72+
import config from "../amplifyconfiguration.json";
73+
74+
Amplify.configure(
75+
{
76+
...config,
77+
Auth: {
78+
Cognito: {
79+
identityPoolId: config.aws_cognito_identity_pool_id,
80+
userPoolClientId: config.aws_user_pools_web_client_id,
81+
userPoolId: config.aws_user_pools_id,
82+
allowGuestAccess: true,
83+
},
84+
},
85+
}
86+
);
8887
```
8988
</Accordion>
9089
</Callout>

0 commit comments

Comments
 (0)