Update fieldkit consumer to only use refresh_token and password grants
This commit is contained in:
parent
d0e305d0c1
commit
4226394e74
|
@ -17,9 +17,13 @@ function farm_fieldkit_install() {
|
|||
'label' => 'Field Kit',
|
||||
'client_id' => 'fieldkit',
|
||||
'access_token_expiration' => 3600,
|
||||
'grant_types' => [
|
||||
'refresh_token',
|
||||
'password',
|
||||
],
|
||||
'redirect' => 'https://farmOS.app',
|
||||
'allowed_origins' => 'https://farmos.app',
|
||||
'owner_id' => '',
|
||||
'owner_id' => NULL,
|
||||
'secret' => NULL,
|
||||
'confidential' => FALSE,
|
||||
'third_party' => FALSE,
|
||||
|
|
|
@ -9,7 +9,20 @@
|
|||
* Enable simple oauth password grant.
|
||||
*/
|
||||
function farm_fieldkit_post_update_enable_password_grant(&$sandbox = NULL) {
|
||||
|
||||
// Enable password grant module.
|
||||
if (!\Drupal::service('module_handler')->moduleExists('simple_oauth_password_grant')) {
|
||||
\Drupal::service('module_installer')->install(['simple_oauth_password_grant']);
|
||||
}
|
||||
|
||||
// Update existing fieldkit consumer.
|
||||
$consumers = \Drupal::entityTypeManager()->getStorage('consumer')
|
||||
->loadByProperties(['client_id' => 'fieldkit']);
|
||||
if (!empty($consumers)) {
|
||||
/** @var \Drupal\consumers\Entity\ConsumerInterface $fieldkit */
|
||||
$fieldkit = reset($consumers);
|
||||
$fieldkit->set('user_id', NULL);
|
||||
$fieldkit->set('grant_types', ['refresh_token', 'password']);
|
||||
$fieldkit->save();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue