!include ../../../styles/PlantUML_StyleSheet.puml

actor "User" as user
participant "Client app\nor paired app" as app #9EA0CA
participant CEK as cek #05D686
actor "Developer" as dev #9EA0CA
participant Extension as ext #9EA0CA
participant "Authorization server" as auth #9EA0CA

dev ->> cek: Registers authentication information (OAuth 2.0)\l- Authorization URI\l- Client ID\l- Client secret\l- Redirect URI\l- Access token URI\l- ...

activate cek
deactivate cek

user ->> app: Enables extension

activate app
  app ->> cek: Requests the authorization URI

  activate cek
    cek -->> app: Returns the authorization URI
  deactivate cek

  app ->> auth: Requests the login page (authorization URI)

  activate auth
    auth -->> app: Returns the login page
  deactivate auth

  app -> app: Displays the login page
  user ->> app: Authenticates the account (login)
  app ->> auth: Requests the authorization

  activate auth
  auth -->> app: Returns the Authorization code\lor access token with redirect URI
  deactivate auth

  app ->> cek: Passes the\lauthorization code\lor access token
deactivate app

  activate cek
    cek ->> auth: Passes the authorization code as a parameter to the access token URI
    activate auth
      auth -->> cek: Returns the access token
    deactivate auth

    cek -> cek: Saves the access token\nto user account information
    cek ->> ext: Sends the user request with the access token
    deactivate cek
    activate ext
