diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index a78913b7e16..30d22c491ee 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -1,6 +1,7 @@ * Copyright (C) 2014-2018 Frederic France + * Copyright (C) 2020 Nicolas ZABOURI * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -155,6 +156,9 @@ if ($mode == 'setup' && $user->admin) // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service). // We pass this param list in to 'state' because we need it before and after the redirect. $shortscope = 'userinfo_email,userinfo_profile,cloud_print'; + if(!empty($conf->global->OAUTH_GSUITE)){ + $shortscope .= ',admin_directory_user'; + } //$scope.=',gmail_full'; $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php'); diff --git a/htdocs/includes/OAuth/OAuth2/Service/Google.php b/htdocs/includes/OAuth/OAuth2/Service/Google.php index 0d49609dccb..5ab0f8a474b 100644 --- a/htdocs/includes/OAuth/OAuth2/Service/Google.php +++ b/htdocs/includes/OAuth/OAuth2/Service/Google.php @@ -116,6 +116,11 @@ class Google extends AbstractService // Android Publisher const SCOPE_ANDROID_PUBLISHER = 'https://www.googleapis.com/auth/androidpublisher'; + + // Google Gsuite + const SCOPE_ADMIN_DIRECTORY_USER = "https://www.googleapis.com/auth/admin.directory.user"; + const SCOPE_ADMIN_DIRECTORY_CUSTOMER = "https://www.googleapis.com/auth/admin.directory.customer"; + protected $accessType = 'online'; public function __construct( @@ -150,7 +155,7 @@ class Google extends AbstractService } $this->approvalPrompt = $prompt; } - + /** * {@inheritdoc} */