Skip to content

Conversation

@jwoptio
Copy link
Contributor

@jwoptio jwoptio commented Jan 9, 2018

This adds an option 'access-token-header' to allow the user to set a HTTP header on which to pass the access token along with the request. This is required when using a custom authorizer as described here: https://aws.amazon.com/blogs/mobile/integrating-amazon-cognito-user-pools-with-api-gateway/.

Copy link
Member

@jayair jayair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. This looks great. Just a couple of questions and pointers. Let me know what you think.

index.js Outdated
console.log("Getting temporary credentials");

var logins = {};
const { idToken, accessToken } = userTokens;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use vanilla JS here? Just so we can support most versions of Node.

index.js Outdated
status: result.status,
statusText: result.statusText,
data: result.data
data: JSON.stringify(result.data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was leaving it as an object since Node does a good job of formatting objects in the console. Any reason why you wanted to stringify it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey it seems that when I don't stringify I just get the top level properties of the result displayed and I wanted to see the full (deep) object. I'm hitting a graphql endpoint so the response looks like this:

Authenticating with User Pool
Getting temporary credentials
Making API request
{ status: 200,
  statusText: 'OK',
  data:
   { data: { vendors: [Array] },
     extensions: { tracing: [Object] } } }

The interesting part of the result is in that Array. I can switch this back to not use stringify but maybe it should be another option.

index.js Outdated
status: result.response.status,
statusText: result.response.statusText,
data: result.response.data
data: JSON.stringify(result.response.data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just checking why the need to stringify.

@jayair
Copy link
Member

jayair commented Jan 19, 2018

Awesome! Thanks.

@jayair jayair merged commit 18debb6 into AnomalyInnovations:master Jan 19, 2018
@jwoptio jwoptio deleted the access-token-header branch August 16, 2018 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants