Week 18 - Session 1 - User Authentication - OAuth 2.0

blog image source
OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service, such as Facebook, GitHub, and Google. It works by delegating user authentication to the service that hosts the user account and authorizing third-party applications to access the user account. OAuth 2 provides authorization flows for web and desktop applications, and mobile devices.

OAuth2 defines 4 roles :
  • Resource Owner: generally yourself.
  • Resource Server: server hosting protected data (for example Google hosting your profile and personal information).
  • Client: application requesting access to a resource server (it can be your PHP website, a Javascript application or a mobile application).
  • Authorization Server: server issuing access token to the client. This token will be used for the client to request the resource server.
There are 4 separate modes of AuthO, which are called grant types. Each mode serves a different purpose and is used in a different way. Depending on what type of service you are building, you might need to use one or more of these grant types to make stuff work.

The Authorization Code Grant Type; used on web servers. You’ll want to use the authorization code grant type if you are building a web application with server-side code that is NOT public. If you want to implement an AuthO flow in a server-side web framework like Express.js, Flask, Django, Ruby on Rails, an Authorization Code is the way to go.

The Implicit Grant Type; used for client-side web applications (like React.js or Angular.js) that don’t have a server-side component — or any sort of mobile application that can use a mobile web browser. Implicit grants are ideal for client-side web applications and mobile apps because this grant type doesn’t require you to store any secret key information at all — this means you can log someone into your site/app WITHOUT knowing what your application’s client_secret is.

The Password Credentials Grant Type; used for first-class web applications OR mobile applications. This is ideal for official web and mobile apps for your project because you can simplify the authorization workflow by ONLY asking a user for their username and password, as opposed to redirecting them to your site, etc.

The Client Credentials Grant Type; used for application code. You’ll want to use the client credentials grant type if you are building an application that needs to perform non-user related tasks. For instance, you might want to update your application’s metadata.

Auth0 - https://auth0.com/
Passwordless Authentication with React and Auth0 - https://medium.com/javascript-scene/passwordless-authentication-with-react-and-auth0-c4cb003c7cde

Popular posts from this blog

Week 9 to 12 - Learning with MCR Codes

Week 9 - Session 1 - The Internet, the Web, HTTP

Week 8 - Session 1 - JavaScript in the Browser