if (!empty($iprestriction)) {
$newtoken->iprestriction = $iprestriction;
}
- $newtoken->privatetoken = null;
+ // Generate the private token, it must be transmitted only via https.
+ $newtoken->privatetoken = random_string(64);
$DB->insert_record('external_tokens', $newtoken);
return $newtoken->token;
}
$newtoken->contextid = context_system::instance()->id;
$newtoken->creatorid = $userid;
$newtoken->timecreated = time();
- $newtoken->privatetoken = null;
+ // Generate the private token, it must be transmitted only via https.
+ $newtoken->privatetoken = random_string(64);
$DB->insert_record('external_tokens', $newtoken);
}