Oauth for native applications (with PKCE) ┌─┐ ┌───┐ ┌───┐ ┌────┐ ┌───┐ │u│ │bro│ │app│ │auth│ │api│ └┬┘ └─┬─┘ └─┬─┘ └──┬─┘ └─┬─┘ │ │ I'd like to use this app │ │ │ │──────────────────────────────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ │ │────┐ │ │ │ │ │ │ I'll generate a secret and hash it (PKCE) │ │ │ │ │<───┘ │ │ │ │ open auth server url with this hash as query string (front-channel) │ │ │ │ │ /auth?response_type={code}& │ │ │ │ │ client_id={client_id}& │ │ │ │ │ redirect_uri={redirect_uri}& │ │ │ │ │ scope={scope}& │ │ │ │ │ state={random_value}& │ │ │ │ │ code_challenge={hash_rand_str}& │ │ │ │ │ code_challenge_method=S256 │ │ │ │ │<─────────────────────────────────────────────────────────────────────│ │ │ │ │ │ │ │ │ │ grant me access, here's the hash (front-channel) │ │ │ │───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ here's a temporary code, exchange for token (front-channel) │ │ │ │<───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ │ │ │ │ │ │ │ │ here's a temporary code │ │ │ │ │ redirect?code={temp_code}&state={state} │ │ │ │ │─────────────────────────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ │ │ here's the code and secret unhashed, give me token │ │ │ │ │ POST /token form_encoded │ │ │ │ │ grant_type=authorization_code& │ │ │ │ │ code={temp_code}& │ │ │ │ │ redirect_uri={redirect_uri}& │ │ │ │ │ code_verifier={rand_str_unhashed}& │ │ │ │ │ client_id={client_id} │ │ │ │ │────────────────────────────────────────────────────>│ │ │ │ │ │ │ │ │ │ │────┐ │ │ │ │ │ │ verify hash of the secret │ │ │ │ │<───┘ │ │ │ │ here's the token │ │ │ │ │<────────────────────────────────────────────────────│ │ │ │ │ │ │ │ │ │ give me data with this token │ │ │ │─────────────────────────────────────────────────────────────────────────────────────>│ │ │ │ │ │ ┌┴┐ ┌─┴─┐ ┌─┴─┐ ┌──┴─┐ ┌─┴─┐ │u│ │bro│ │app│ │auth│ │api│ └─┘ └───┘ └───┘ └────┘ └───┘