mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
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',
|
'label' => 'Field Kit',
|
||||||
'client_id' => 'fieldkit',
|
'client_id' => 'fieldkit',
|
||||||
'access_token_expiration' => 3600,
|
'access_token_expiration' => 3600,
|
||||||
|
'grant_types' => [
|
||||||
|
'refresh_token',
|
||||||
|
'password',
|
||||||
|
],
|
||||||
'redirect' => 'https://farmOS.app',
|
'redirect' => 'https://farmOS.app',
|
||||||
'allowed_origins' => 'https://farmos.app',
|
'allowed_origins' => 'https://farmos.app',
|
||||||
'owner_id' => '',
|
'owner_id' => NULL,
|
||||||
'secret' => NULL,
|
'secret' => NULL,
|
||||||
'confidential' => FALSE,
|
'confidential' => FALSE,
|
||||||
'third_party' => FALSE,
|
'third_party' => FALSE,
|
||||||
|
|
|
@ -9,7 +9,20 @@
|
||||||
* Enable simple oauth password grant.
|
* Enable simple oauth password grant.
|
||||||
*/
|
*/
|
||||||
function farm_fieldkit_post_update_enable_password_grant(&$sandbox = NULL) {
|
function farm_fieldkit_post_update_enable_password_grant(&$sandbox = NULL) {
|
||||||
|
|
||||||
|
// Enable password grant module.
|
||||||
if (!\Drupal::service('module_handler')->moduleExists('simple_oauth_password_grant')) {
|
if (!\Drupal::service('module_handler')->moduleExists('simple_oauth_password_grant')) {
|
||||||
\Drupal::service('module_installer')->install(['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 a new issue