Add Authentication to Any Web Page in 10 Minutes

Does anybody know how I can return the user firstname instead of the email upon a successful login?

1 Like

If you request the scope profile you’ll get the user’s name.

1 Like

Hi,
My app has API scopes for okta.users.read and
so I changed the code to be document.getElementById("messageBox").innerHTML = "Hello, " + idToken.claims.firstName+ "! You just logged in! :)";

But that returns Undefined! What am I doing wrong?

1 Like

okta.users.read is an Okta scope for managing users via the API. Try requesting just the scope profile.

1 Like

Hi, I dont see just a profile scope, can you advise where this is?

1 Like

It’s one of the default OpenID Connect scopes.

https://developer.okta.com/docs/reference/api/oidc/#reserved-scopes

1 Like

I didn’t need to add the scope. I needed to add a claim for the firstname

I have a basic question here. If I am writing an app for my customers to log in via SSO, does it matter whether I choose SAML or OIDC? If my customers use Okta as an IdP and they use SAML, can I still choose OIDC in my app’s integration with Okta and still allow those customers to login via SSO?

1 Like

Yes, both OIDC and SAML will work. However, we recommend you choose OIDC because it’s a newer standard that works with more devices. SAML 2.0 was released in 2006 and is more difficult to work with for developers.