question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing a federated identity into AWSAppSyncClient?

See original GitHub issue

Here’s what im trying to do essentially in React.

  1. User logs in via a login mutation with appsync and is returned an identityId and JWT token from the response.
const cognitoCredentials = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: 'IdentityPool goes here',
  IdentityId: 'IdentityId here',
  Logins: {
     'cognito-identity.amazonaws.com': 'JWT Token here'
  }
});
  1. I pass the credentials with the users identityId And JWT token to Appsync to authenticate them…
const client = new AWSAppSyncClient({
  url: appSyncConfig.graphqlEndpoint,
  region: appSyncConfig.region,
  auth: {
    type: AUTH_TYPE.AWS_IAM,
    credentials: cognitoCredentials
  }
});

My question is… is this the approach I should be taking or is there an easier way of doing this? I don’t want to use user pools because it will end up being too expensive for me; so i’m going the federated identity approach. I will create a user…and save them as a federated identity using their database user id.

Sorry if this is the wrong section, but maybe someone knows!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
honkskilletcommented, May 3, 2018

@lolcoolkat How do you get your custom headers from the client you lambdas. I am using IAM auth and lambdas and AppSync doesn’t seem to pass along headers (unless I am doing it wrong which is very possible).

1reaction
russelltagacommented, Feb 10, 2018

Got it, apologies for any confusion!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to access AppSync API using custom Federated Identity
I'm trying to consume AWS AppSync API using Federated Identities with custom authenticated role but without success.
Read more >
Authorization and authentication - AWS AppSync
Learn about authentication and authorization in AWS AppSync. ... using short-lived, temporary credentials provided by Amazon Cognito Federated Identities.
Read more >
Authentication - GitHub Pages
To federate Google as a user sign-in provider for AWS services called in your app, you will pass tokens to AWSMobileClient.sharedInstance().federatedSignIn() .
Read more >
Authentication - Federated identities - Swift - AWS Amplify Docs
Federated Sign In can be used to obtain federated “Identity ID” using external ... Once you pass the tokens, the AWSMobileClient will fetch...
Read more >
AWS AppSync without Authentication - DEV Community ‍ ‍
The first step is to specify the authentication type in aws-exports.js . ... '@aws-amplify/auth' import AWSAppSyncClient from 'aws-appsync' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found