What are the main differences between JWT and OAuth authentication?

前端 未结 8 537
栀梦
栀梦 2020-12-04 04:25

I have a new SPA with a stateless authentication model using JWT. I am often asked to refer OAuth for authentication flows like asking me to send \'Bearer tokens\' for every

8条回答
  •  被撕碎了的回忆
    2020-12-04 04:46

    OAuth 2.0 defines a protocol, i.e. specifies how tokens are transferred, JWT defines a token format.

    OAuth 2.0 and "JWT authentication" have similar appearance when it comes to the (2nd) stage where the Client presents the token to the Resource Server: the token is passed in a header.

    But "JWT authentication" is not a standard and does not specify how the Client obtains the token in the first place (the 1st stage). That is where the perceived complexity of OAuth comes from: it also defines various ways in which the Client can obtain an access token from something that is called an Authorization Server.

    So the real difference is that JWT is just a token format, OAuth 2.0 is a protocol (that may use a JWT as a token format).

提交回复
热议问题