@startuml actor User boundary AccountPage boundary EtsyPage control AppServer database DB control Etsy User -> AccountPage ++ : load AccountPage -> AppServer ++ : get link to etsy to give app access AppServer -> DB ++ : TODO: store oauth state and code AppServer <-- DB -- AccountPage <-- AppServer -- : link User -> AccountPage : click link User <-- AccountPage -- : redirect User -> EtsyPage ++ : load User <-- EtsyPage User -> EtsyPage : click button to "give app access" EtsyPage -> Etsy ++ AppServer <- Etsy ++ : send auth code AppServer -> DB ++ : get oauth state AppServer <-- DB -- AppServer -> AppServer : verify state AppServer -> Etsy ++ : request access code AppServer <-- Etsy -- : access token and expiration, refresh token, and user_id AppServer -> Etsy ++ : get user's store AppServer <-- Etsy -- AppServer -> DB ++ : save access token, store id, etc AppServer <-- DB -- AppServer --> Etsy -- EtsyPage <-- Etsy : 3xx redirect to app's redirect url (account page) User <-- EtsyPage -- User -> AccountPage : load @enduml