I would like to make single page web application (using ember.js for frontend, django for backend and rest framework for handling APIs), with third party authentication system (facebook/google/linkedin).
Focusing only on google oauth2 I found that this is the oauth2 process(from https://developers.google.com/accounts/docs/OAuth2WebServer)
and I manage to get the authorisation code, but I dont know how to to trade it for acces token with user data, and save them to my db or even better how to call python-social-auth to handle this for me, without reloading the page.
I also checked this tutorial http://psa.matiasaguirre.net/docs/use_cases.html#signup-by-oauth-access-token , but it want acces_token as parameter, not auth code.
What is the best approche to do it?
When using the authorization code flow, your web server/app receives an authentication code when the user authenticates. This particular flow involves one more step as you have already realised - exchanging the authorization code for an access token.
You'd need to to make a call like this to exchange the auth code for an access token,
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7&
client_id=8819981768.apps.googleusercontent.com&
client_secret={client_secret}&
redirect_uri={your_redirect_uri}&
grant_type=authorization_code
Please note, in this particular flow it's a two step authentication - authenticating the user and then the app that makes the calls on behalf of the user. Read this link if you need more info on this.