I tried to add ‘email’ as a claim in id_token, but when I tried to use ‘email’ it complained ‘The claim name must be unique within an authorization server.’
Everything works if I use some other name like ‘user_email’, but I would like to use ‘email’.
If you request the “email” scope, we will automatically include this value in the ID token as the “email” claim, which is why you are seeing this error. Details about the scope-dependent claims found here: OpenID Connect & OAuth 2.0 API | Okta Developer
What flow are you trying to use? You shouldn’t be hitting the token endpoint when completing implicit flow, which is the flow being used when the response_type=id_token.
If you are trying to use implicit flow (which we don’t typically recommend people use at this point as it is less secure that authorization code flow), you’ll want to follow the steps in this guide about how to make the authorize call, in the browser, to get a token back: Implement authorization by grant type | Okta Developer. Make sure the scopes for your requests includes both openid (required for OIDC flows returning an ID token) and email