amazon-archives / amazon-cognito-auth-js

The Amazon Cognito Auth SDK for JavaScript simplifies adding sign-up, sign-in with user profile functionality to web apps.
Apache License 2.0
424 stars 232 forks source link

CodeGrantFlow custom Authorization headers #198

Open srinuhamps opened 5 years ago

srinuhamps commented 5 years ago

I am using codegrant flow and everything as per the documentation works, I'm sure I can work around the silent refresh as well based on the provided comments. But the only issue I've been facing is "unable to set my custom headers"

I have to send Authorization as "Basic xxxxxxxxxx" along with 'Content-Type': 'application/x-www-form-urlencoded' as per my requirement. Unfortunately I don't see any feasibility in doing so.

Let me know if you have any other workaround for achieving this. because I made some modifications in the library and it worked for me.

Below are the changes in file:

HEADER: this.headers in constants header = { ...header }; in makePOSTRequest method.

Below is the configuration:

authData: { tenant: 'tenant', ClientId: 'ClientId', AppWebDomain: 'AppWebDomain', TokenScopesArray: ['openid'], RedirectUriSignIn: window.location.origin, UserPoolId: 'UserPoolId', RedirectUriSignOut: window.location.origin, grant_type: 'grant_type', client_secret: 'client_secret', cacheLocation: 'localStorage', IdentityProvider: 'IdentityProvider', AdvancedSecurityDataCollectionFlag: false, headers: { 'Content-Type': 'application/x-www-form-urlencoded', Authorization: 'Basic XDXDXDXGFXHGGFXFXFXFXFXXDXDXDXDXDXDDXDXDX' } }

I have also attached the modified file here.

CognitoAuth.txt

I have a critical deadline to fix this issue. Appreciate your quick thoughts on this.