You are here

private function BackupMigrateDropboxAPI::refresh_bearer_token in Backup and Migrate Dropbox 7.3

Refreshes and returns an expired bearer token.

If a bearer token expires, it needs to be refreshed, i.e. replaced by a new short lived (typically 4 hours) bearer token. We store these in a variable but also return it as it is needed directly.

Return value

string The refreshed bearer token for this Dropbox destination.

Throws

RuntimeException

2 calls to BackupMigrateDropboxAPI::refresh_bearer_token()
BackupMigrateDropboxAPI::get_bearer_token in ./backup_migrate_dropbox.dropbox_api.inc
Returns a short lived but not yet expired bearer token.
BackupMigrateDropboxAPI::send_message in ./backup_migrate_dropbox.dropbox_api.inc
Sends a request to Dropbox and returns the response.

File

./backup_migrate_dropbox.dropbox_api.inc, line 230

Class

BackupMigrateDropboxAPI
BackupMigrateDropboxAPI contains all the details about the Dropbox api, authorization calls, endpoints, uris, parameters, error handling, and split requests for large uploads/downloads

Code

private function refresh_bearer_token() {
  $parameters = [
    'refresh_token' => $this
      ->get_refresh_token(),
    'grant_type' => 'refresh_token',
    'client_id' => $this
      ->get_app_id(),
  ];
  $response = $this
    ->send_message('api', 'oauth2/token', $parameters);
  return BearerTokenInfos::set($this->destination
    ->get_id(), $response);
}