So I have a Single Page Client App.
Normal flow:
App -> OAuth2 server -> App
We have our own OAuth2 server, so people can login to the app and get an access_token associated with the User entity. http://api.com/oauth2/auth?access_token=X&redirect_uri=http://app.com&response_type=token
Our special flow..
We also have this special endpoint /oauth2/vendor/facebook/auth?client_id=Xredirect_uri=http://app.com
App[1] -> OAuth2 server[2] -> Facebook[3] -> OAuth2 server[4] -> App[5]
[2]: We urlencode the redirect_uri and pass it as a custom parameter to facebook, so we can redirect to http://app.com later on..
[3]:
We redirect the Client to facebook for authentication and acccept app.
[4]:
- Facebook redirects to oauth server, we get the 'code'.
- We ask for an access_token, we get the access_token. This all happens behind the scene with CURL.
- We ask our own API (internal API call to localhost) with a custom grant type (we name it http://api.com/facebook per oauth2 specification), this. This is done with a client secret and is happening behind the scene with CURL.
- We redirect to the original redirect_uri, originally provided.
It this an applicable way of authenticating with facebook as well?
We know that this can be done in another way, e.g. the Browser first asks for a facebook token, then the browser asks for an access_token that finally gets passed to our own oauth2 endpoint for further validation and processing, that's two requests for the client which to me seems rather slow and cumbersome to me. Or is it?