// services/authorization_server.ts const authorizationServer =newAuthorizationServer( clientRepository, accessTokenRepository, scopeRepository, "secret-key", ); authorizationServer.enableGrantType("client_credentials"); authorizationServer.enableGrantType({ grant:"authorization_code", userRepository, authorizationCodeRepository, }); // other grant types you want to enable
Which Grant?
+-------+ | Start | +-------+ V | +------------------------+ +-----------------------+ | Have a refresh token? |>----Yes----->| Refresh Token Grant | +------------------------+ +-----------------------+ V | No | +---------------------+ | Who is the | +--------------------------+ | Access token owner? |>---A Machine---->| Client Credentials Grant | +---------------------+ +--------------------------+ V | | A User | | +----------------------+ | What type of client? | +----------------------+ | | +---------------------------+ |>-----------Server App---------->| Auth Code Grant with PKCE | | +---------------------------+ | | +---------------------------+ |>-------Browser Based App------->| Auth Code Grant with PKCE | | +---------------------------+ | | +---------------------------+ |>-------Native Mobile App------->| Auth Code Grant with PKCE | +---------------------------+