Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
What is the difference between ID token and access token, and how to implment them using JWT?

So i have been reading about the difference between ID token and access token is for authorization. I don't know how to implement the ID token, which should be a JWT.

The access token i have been implementing looks like this:

const accountCredentials = {
    username: account.username,
    accountId: account.accountId,
    grant_type: "password"
}

const token = jwt.sign(accountCredentials, config.JWT_KEY, { expiresIn: "1h" })

so i wonder, what is an ID token supposed to contain and how to implement it as described by the openID connect specification. I'm sorry, this might sound stupid but i really don't understand the documentation.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

An ID token is a token which allows your app to identify the user. It is always a JWT, and it's contents are described in this section of the OIDC docs: https://openid.net/specs/openid-connect-core-1_0.html#IDToken So to have a valid ID token, you need a JWT which contains at least these claims: iss, sub, aud, exp, iat. You can check in the spec, what each of these claims should contain. Additionally, the ID token must be at least signed (it can also be encrypted).

In your code you will have something like that:

const accountCredentials = {
    iss: '...',
    sub: account.username,
    aud: '...',
    iat: now()
}

const token = jwt.sign(accountCredentials, config.JWT_KEY, { expiresIn: "1h" })

Note that OpenID Connect spec only specifies authorization code, implicit and hybrid flows. Using password grant type is not part of the OIDC standard.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda