Server Side

The following workflow shows the process to get an access token the first time (you'll also get a refresh token):

Because an access token expires, when it happens, you need to ask for a new one with the refresh token you got in step 2.
The following workflow shows the process to get a new access token by exchanging your refresh token:
First, you need to register your app before starting.