Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Bearer tokens (OAuth2) are created?

I want to know, what is the internal process to encrypt and decrypt a Bearer token used in OAuth2 and the code in Asp.Net Identity.

Once the server receives a token, it is able to retrieve the UserId, Roles, Claims and all properties inside it. So, how are Bearer tokens decrypted? What is encryption algorithm and the code used?

like image 495
Xavier Egea Avatar asked Sep 16 '14 21:09

Xavier Egea


1 Answers

Where are you obtaining the token from? Tokens are seldom encrypted (sometimes they are), but they will always be encoded (and signed). OpenID (a protocol on top of OAuth2) uses JWT. OAuth2 (not OpenID) uses "opaque" tokens.

See http://jwt.io for libraries on decoding a JWT.

like image 67
Eugenio Pace Avatar answered Oct 31 '22 09:10

Eugenio Pace