You are here

public function BackupMigrateDropboxAPI::create_code_verifier in Backup and Migrate Dropbox 7.3

Makes a Dropbox code verifier for this installation.

@link https://dropbox.tech/developers/pkce--what-and-why-

Return value

string A Dropbox code verifier.

Throws

Exception

File

./backup_migrate_dropbox.dropbox_api.inc, line 108

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

public function create_code_verifier() {
  if (version_compare(phpversion(), '7.0', '>=')) {

    /** @noinspection PhpElementIsNotAvailableInCurrentPhpVersionInspection */
    $random = random_bytes(32);
  }
  else {
    $random = '';
    while (strlen($random) < 32) {
      $random .= chr(mt_rand(0, 255));
    }
  }
  return $this
    ->base64_url_encode($random);
}