facebook - Getting the Cognito Identity ID when I am on a different page -


i able log in user used facebook authenticate. worked fine , page got redirected page expected. code given below.

my question how can retrieve user id (or cognito identity id) when on page ? (not in same page but, when on page)

aws.config.region='us-east-1';         aws.config.credentials = new aws.cognitoidentitycredentials({              // either identitypoolid or identityid required             // see identitypoolid param aws.cognitoidentity.getid (linked below)             // see identityid param aws.cognitoidentity.getcredentialsforidentity             // or aws.cognitoidentity.getopenidtoken (linked below)             identitypoolid: cognitoidentitypoolid,              // optional, necessary when identity pool not configured             // use iam roles in amazon cognito console             // see rolearn param aws.sts.assumerolewithwebidentity (linked below)             rolearn: 'arn:aws:iam::9287589741169:role/cognito_111auth_role',              // optional tokens, used authenticated login             // see logins param aws.cognitoidentity.getid (linked below)             logins: {               'graph.facebook.com': accesstoken             },              // optional name, defaults web-identity             // see rolesessionname param aws.sts.assumerolewithwebidentity (linked below)             rolesessionname: 'web',              expired: 'true'            });         console.log('refreshing cognito credentials');         aws.config.credentials.refresh(function(err) {           if (err) {               console.log('failed refresh');               return;           } else {               aws.config.credentials.get(function(err){                   if (!err) {                     var id = aws.config.credentials.identityid;                     console.log('cognito identity id '+ id);                   }               });                var s3 = new aws.s3();               console.log('creds '+ s3.config.credentials.sessiontoken);           }           });        } 

the identity id cached between page loads, , can retrieved

var identityid = aws.config.credentials.identityid;

credentials not cached, , need credentials each time.

this forum post may help: https://forums.aws.amazon.com/thread.jspa?threadid=179420&tstart=25


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -