Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2: Make Outlook Work Again #292

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions auth-oauth2/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function getClientSecret() {
return $this->get('clientSecret');
}

public function getScopes() {
return array_map('trim',
explode(',', $this->get('scopes', [])));
public function getScopes($key='scopes') {
return array_filter(array_map('trim',
explode(',', $this->get($key, []))));
}

public function getAuthorizationUrl() {
Expand Down Expand Up @@ -360,7 +360,7 @@ public function getFormOptions() {
}

// This is necessay so the parent can reject updates on Autho instances via plugins
// intervace which is doesn't have re-authorization capabilities at the
// interface which doesn't have re-authorization capabilities at the
// moment.
function pre_save(&$config, &$errors) {
return true;
Expand All @@ -373,3 +373,26 @@ function getFields() {
);
}
}

class OAuth2MicrosoftEmailConfig extends OAuth2EmailConfig {

function getFields() {
list($__, $_N) = self::translate();
$fields = parent::getFields();
// Add Outlook Mail Scopes field after access token endpoint
$pos = array_search('urlAccessToken', array_keys($fields), true) + 1;
return array_slice($fields, 0, $pos, true) + [
// Outlook Mail Scopes without resource scopes
'scopes' => new TextboxField([
'label' => $__('Outlook Scopes'),
'hint' => $__('Space separated Outlook Scopes for desired services'),
'required' => true, // Required!
'configuration' => [
'size' => 64,
'length' => 0
],
]
),
];
}
}
Loading