We know:
In the OAuth 2.0
in Authorization Code Flow
there are several entity:
- A)
User
- B) User Agent (
Browser
) - C) Client App (
Mobile App
) - D) Confidential Client (Middleman
Web Server
) - E)
Authorization Server
Also we know that the the Web Server
keep the Client Secret
and the /token
route of Authorization Server
need Authorization Code
and Client Secret
to return the Access Token
.
My Question:
When the User login to the Authorization Provider
by browser
and Authorization Server
return the Authorization Code
to the redirect URL (to the Web Server
) which one of the following ways exactly SHOULD be done? Why?
X)
- The
Web Server
should return theAuthorization Code
as a response to theBrowser
in appropriate deep-linking format. - The
Browser
open theMobile App
and pass theAuthorization Code
to it - The
Mobile App
use PKCE to send theAuthorization Code
to theWeb Server
(by calling an API) and theWeb Server
sends the request toAuthorization Server
to get theAccess token
and it will be return to theMobile App
.
Y)
- The
Web Server
should get theAccess Token
by the receivedAuthorization Code
and return theAccess Token
as a response to the browser in deep-linking format. - The
Browser
open theMobile App
and pass theAccess Token
to it.
I have seen the bellow diagram here:
And think the correct way is X because in the X way the Mobile App
get the Access Token
directly by API
without the Browser
deep-linking and X is secure. But I need a valid document and reference to official documentation in the answers.
I want to be sure... Which one is correct way? X or Y?
.