amplify-js: Does aws-amplify support guest/unauthorized user?
I learned from AWS re:Invent 2017: Analytics, Authentication and Data with JavaScript: AWS Amplify (MBL403) https://www.youtube.com/watch?v=vAjf3lyjf8c&t=367s , seems that the aws-amplify is capable of handling guest users (unauthorized user).
And I am using aws-appsync as my backend, I don’t want my mobile client to have signed-in, but I want them to be a unique ID. Here is my config for aws-appsync client.
const client = new AWSAppSyncClient({
url: AppSync.graphqlEndpoint,
region: AppSync.region,
auth: {
// Amazon Cognito Federated Identities using AWS Amplify
credentials: () => Auth.currentCredentials()
},
});
, then I looked over the aws-amplify document and seems the federatedSignIn is the right API, but it doesn’t mention anything about guest users (unauthorized user).
Does aws-amplify support guest/unauthorized user and what is the API? Many thanks
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 33 (12 by maintainers)
To setup Unauthenticated Access in your app, first off you need to set up Amazon Cognito to allow unauthenticated users.
see for more https://docs.aws.amazon.com/cognito/latest/developerguide/identity-pools.html
Once you have set that up, then within your app all you need to do is call the currentCredentials method
which responds with an anonymous identity you can use in your app. This will work if of course you don’t have a real user signed in already.
Dear Aws-amplify developer
Do you have any update on this toppic? especially how to sey up the configure file or the attach the accesstoken to aws-amplify-graphOperation
I am stuck with this for long time. If you have any sample code please share me
thanks
@bishonbopanna No ETA yet but it’s currently on the roadmap and definitely a priority.
@CodySwannGT correct the multi auth GraphQL directives are not supported in the Amplify CLI yet, but that release is soon. You can track the PR here: https://github.com/aws-amplify/amplify-cli/pull/1524 However you can always go to the AppSync console for your API by running
amplify consoleand then annotating your schema manually until that PR releases. Alternatively you can can use IAM authorization on your GraphQL API with Cognito Federated Identities which supports Guest access.We’re currently working on making this easier via the CLI, but if you come upon this issue I’ve written up the steps on how to get this working at https://github.com/dabit3/appsync-auth-and-unauth.
^ how do you set that up/do that?
I’m gonna drop this since multiple discord users have been asking how to setup UN-authenticated users on their app. This should be preferred over using
API_KEYas it is meant for development usage and tends to expire.Amplify CLI:
amplify add apiCognitoas your main authentication method.IAM(otherwise, go throughamplify update apiagain).amplify update auth.Walkthrough auth settingsamplify push. (you might want to update the schema first)Schema example: Take note of the auth directive used.
In your app:
Let me know if it helps, I’ll polish the instructions when I have time to spare
Thankyou @dabit3 for the response.
Created this article as a bonus to https://github.com/dabit3/appsync-auth-and-unauth to answer some specifics for using congnitoIdentityId to get the authorization right till the more permanent solution is rolled out.
https://medium.com/@bishonbopanna/appsync-how-to-allow-guest-access-while-limiting-authenticated-users-access-to-only-what-they-bfbb5b0c5706
Wouldn’t they just follow a sign up process?
On Mon, Dec 7, 2020 at 9:44 AM nubpro notifications@github.com wrote:
–
Mithun Kalan mithunkalan@gmail.com
To be clear, currently Amplify does not support the multiple auth implementation of AppSync, so if I understand this correctly, it is currently impossible to allow guest access with cognito pool auth on.
We have a boot workaround that we’d love to get rid of:
@sakhmedbayev great idea, we’ll go ahead and add this to the docs.