This guide explains some common scenarios of portability so you can build your app with the configuration to fit your needs.
Access tokens are portable. Once you obtain a token, you can use it from any machine. When you combine web interfaces, mobile clients, and servers, you can get a mix of different possible configurations. However, these different configurations come with different advantages and disadvantages in terms of capabilities and security.
Configuration | Advantages | Disadvantages | Security Notes |
---|---|---|---|
Login and API requests happen in a web client (short term token). | Simple implementation. | No offline posting. No long term access. Authenticate often. | |
Login and API requests happen in a native mobile or web client (long term token). | Authenticate less often. | No offline posting. | |
Login and API requests happen in a web client (long term token after code exchange). | Extra security in certain situations. | Difficult to implement. No offline posting. | Only useful in specific situations. |
Login happens in a native mobile or web client. API requests happen on a Server (with long term token). | Offline posting. Add security features available with server based calls. | Client must call the server to proxy any calls. | Use |
Login happens in a native mobile or web client. API requests happen on a server or in the client. | Offline posting User-driven posting from client | Difficult to implement | Use |
This is the simplest configuration where authentication and API requests happen on the client. There are three possible configurations in this model:
In this common configuration, authentication happens on the client, but all API calls are made by the server on behalf of the client. The server can use the appsecret_proof
parameter to further enhance security when making calls.
This configuration is a combination of the above approaches.
There are different ways to specify which access token to use with an API call in our SDKs.
setCurrentAccessToken
method has the accessToken
parameter.setCurrentAccessToken
method has the token
parameter.FB.api()
method has the access_token
parameter.