You are here

public static function BearerTokenInfos::set in Backup and Migrate Dropbox 7.3

Stores a bearer token that was obtained from Dropbox.

Parameters

string $id: The id (machine name) of the current Dropbox destination.

object $response: The (successful) response as received from Dropbox.

Return value

string The newly received (and thus valid) bearer token for the current Dropbox destination.

2 calls to BearerTokenInfos::set()
BackupMigrateDropboxAPI::obtain_refresh_token in ./backup_migrate_dropbox.dropbox_api.inc
Obtains a first bearer and a refresh token.
BackupMigrateDropboxAPI::refresh_bearer_token in ./backup_migrate_dropbox.dropbox_api.inc
Refreshes and returns an expired bearer token.

File

./backup_migrate_dropbox.dropbox_api.inc, line 889

Class

BearerTokenInfos
Class BearerTokenInfos manages the bearer tokens.

Code

public static function set($id, $response) {
  $bearer_tokens = BearerTokenInfos::get_all();
  $bearer_tokens[$id] = (object) [
    'access_token' => $response->access_token,
    'expires' => time() + (int) $response->expires_in,
  ];
  variable_set('backup_migrate_dropbox_bearer_tokens', json_encode($bearer_tokens));
  return $response->access_token;
}