Skip to content

Commit be0d445

Browse files
billyboothbgavrilMS
authored andcommitted
Align DeviceCodeRequest/UsernamePasswordRequest scopes construction with TokenClient/ScopeHelper
* Brings DeviceCodeRequest and UsernamePasswordRequest scopes production into somewhat better alignment with TokenClient.GetDefaultScopes(). * Allows OAuth2Value.ReservedScopes to be respected across all grant types.
1 parent 7890844 commit be0d445

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/client/Microsoft.Identity.Client/Internal/Requests/DeviceCodeRequest.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ protected override async Task<AuthenticationResult> ExecuteAsync(CancellationTok
3131

3232
var client = new OAuth2Client(ServiceBundle.ApplicationLogger, ServiceBundle.HttpManager, null);
3333

34-
var deviceCodeScopes = new HashSet<string>();
35-
deviceCodeScopes.UnionWith(AuthenticationRequestParameters.Scope);
36-
deviceCodeScopes.Add(OAuth2Value.ScopeOfflineAccess);
37-
deviceCodeScopes.Add(OAuth2Value.ScopeProfile);
38-
deviceCodeScopes.Add(OAuth2Value.ScopeOpenId);
34+
var deviceCodeScopes = new HashSet<string>(AuthenticationRequestParameters.Scope);
35+
deviceCodeScopes.UnionWith(OAuth2Value.ReservedScopes);
3936

4037
client.AddBodyParameter(OAuth2Parameter.ClientId, AuthenticationRequestParameters.AppConfig.ClientId);
4138
client.AddBodyParameter(OAuth2Parameter.Scope, deviceCodeScopes.AsSingleString());

src/client/Microsoft.Identity.Client/Internal/Requests/UsernamePasswordRequest.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,9 @@ private Dictionary<string, string> GetAdditionalBodyParameters(UserAssertion use
187187
dict[OAuth2Parameter.Password] = _usernamePasswordParameters.Password;
188188
}
189189

190-
ISet<string> unionScope = new HashSet<string>()
191-
{
192-
OAuth2Value.ScopeOpenId,
193-
OAuth2Value.ScopeOfflineAccess,
194-
OAuth2Value.ScopeProfile
195-
};
190+
var unionScope = new HashSet<string>(AuthenticationRequestParameters.Scope);
191+
unionScope.UnionWith(OAuth2Value.ReservedScopes);
196192

197-
unionScope.UnionWith(AuthenticationRequestParameters.Scope);
198193
dict[OAuth2Parameter.Scope] = unionScope.AsSingleString();
199194
dict[OAuth2Parameter.ClientInfo] = "1";
200195

0 commit comments

Comments
 (0)