okta / okta-auth-js

The official js wrapper around Okta's auth API
Other
453 stars 265 forks source link

Unable to get User Information in Vuejs #545

Open ipxat opened 3 years ago

ipxat commented 3 years ago

I am unable to get User Information like name, email, profile details from auth-js, i think that code is in Typescript, do you have any working example in vuejs/javascript with user profile

aarongranick-okta commented 3 years ago

To receive username and email you should add "email" and "profile" to the list of scopes, as shown here: https://github.com/okta/samples-js-vue/blob/master/okta-hosted-login/src/config.js#L8

The values will be available as properties of the "claims" object on the ID token: https://github.com/okta/samples-js-vue/blob/master/okta-hosted-login/src/components/Home.vue#L35

You can also call getUser to obtain the user's profile from the Okta backend: https://github.com/okta/samples-js-vue/blob/master/okta-hosted-login/src/components/Home.vue#L83

ipxat commented 3 years ago

i am trying to call getUserInfo method authClient.token.getUserInfo(this.getToken()) .then(function (user) { console.log('user', user); });

i am getting following error AuthSdkError: getUserInfo requires an access token object

shuowu commented 3 years ago

@ipxat Can you try authClient.getUserInfo