Unable to get all user claims from getuser()

Hi,

I am new to okta platform.

I had successfully implemented okta login widget to my angular SPA and I’m unable to get user data.

Below is my code.

import {OktaAuthService} from ‘@okta/okta-angular’;

constructor(private oktaService: OktaAuthService) { }

this.oktaService.getUser();

getting reponse =>
{“sub”:“00u174htqa0oWTBvf357”,
“companyID”:34,
“company_id”:34,
“adminappgroups”:[“GSAdminApp-Admin”]
}

needed response =>
{“sub”:“00u174htqa0oWTBvf357”,
“name”:“Naresh P”,“locale”:“en-US”,
email":"naresh.palle@abc.com”,
preferred_username":"naresh.palle@abc.com”,
“given_name”:“Naresh”,
“family_name”:“P”,
“zoneinfo”:“America/Los_Angeles”,
“updated_at”:1566805575,
“email_verified”:true,
“companyID”:34,
“adminappgroups”:[“GSAdminApp-Admin”],
“groups”:[“GSAdminApp-Admin”]
}

My claims in okta

My scopes

Thanks,
Gaurav Abbhi

Hi @Gaurav

In Okta, please switch the claims from being present always inside the ID token to being present on /UserInfo endpoint. In this way, you should be able to retrieve them successfully through the SDK.

Hi, thanks for the the fast response.

I’ve changed all the claims to /userinfo endpoint.

Previous one was
image

Still getting same response =>
getting reponse =>
{“sub”:“00u174htqa0oWTBvf357”,
“companyID”:34,
“company_id”:34,
“adminappgroups”:[“GSAdminApp-Admin”]
}

Thanks,

Are you just looking to get the basic user profile information from your /userinfo call?

If so, are you including the ‘profile’ scope in your /authorize request?

If the question is why some of those custom claims are not appearing in the response from the userinfo endpoint, does the user you are testing with have values for these profile attributes? If there is no value present for an attribute mapped to a claim, the claim will not be included in the token/userinfo output.

Hi @andreaskouras , thanks for your reply.

I had checked my /authorize request it did’t include profile scope although I am passing scope like this.

widget = new OktaSignIn({
        baseUrl: environment.okta_config.url,
        redirectUri: environment.okta_config.redirectUri,
        authParams: {
            // pkce: true,
            // issuer: environment.okta_config.issuer,
            responseType: ['id_token', 'token'],

> scopes: ['openid', 'email', 'profile','groups']

}
    });

Any guess what’s the problem here do I’m missing anything.

Thanks,

Hi @Gaurav

Can you please add inside authParams{} an issuer with the issuer URL available in Okta under Settings tab inside the authorization server administrative window?

The final configuration should look like the following:

widget = new OktaSignIn({
    baseUrl: environment.okta_config.url,
    redirectUri: environment.okta_config.redirectUri,
    authParams: {
        // pkce: true,
        // issuer: environment.okta_config.issuer,
        responseType: ['id_token', 'token'],
        scopes: ['openid', 'email', 'profile', 'groups'],
        issuer: "https://yourOrg.okta.com/oauth2/default"

    }
});

Yes, I add the issuer also.
/authorize URL did’t getting parameters after openid.

Hi @Gaurav

Can you please open a support ticket with us through an email to developers@okta.com in order to further check the configuration?

1 Like