Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit 48d8da9

Browse files
Merge pull request #2727 from pnp/dev
June 2020 Intermediate Release 2
2 parents b812c37 + c297004 commit 48d8da9

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1313

1414
### Contributors
1515

16+
## [3.22.2006.2]
17+
18+
Intermediate release due to a fix in the underlying Core Library and the Connect-PnPOnline cmdlet.
19+
1620
## [3.22.2006.1]
1721

1822
Intermediate release due to a fix in the underlying Core Library.

Commands/Base/PnPConnection.cs

+31-29
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public class PnPConnection
4949
/// Indication for telemetry through which method a connection has been established
5050
/// </summary>
5151
public InitializationType InitializationType { get; protected set; }
52-
52+
5353
/// <summary>
5454
/// If provided, it defines the minimal health score the SharePoint server should return back before executing requests on it. Use scale 0 - 10 where 0 is most health and 10 is least healthy. If set to NULL, no health score check will take place.
5555
/// </summary>
5656
public int? MinimalHealthScore { get; protected set; }
57-
57+
5858
public int RetryCount { get; protected set; }
5959
public int RetryWait { get; protected set; }
6060
public PSCredential PSCredential { get; protected set; }
@@ -130,7 +130,7 @@ internal GenericToken TryGetToken(TokenAudience tokenAudience, string[] roles =
130130
if (token.ExpiresOn > DateTime.Now)
131131
{
132132
// Token is still valid, ensure we dont have specific roles to check for or the requested roles to execute the command are present in the token
133-
if(roles == null || roles.Length == 0 || roles.Any(r => token.Roles.Contains(r)))
133+
if (roles == null || roles.Length == 0 || roles.Any(r => token.Roles.Contains(r)))
134134
{
135135
return token;
136136
}
@@ -146,7 +146,7 @@ internal GenericToken TryGetToken(TokenAudience tokenAudience, string[] roles =
146146
}
147147

148148
// We do not have a token for the requested audience yet or it was no longer valid, try to create (a new) one
149-
switch(tokenAudience)
149+
switch (tokenAudience)
150150
{
151151
case TokenAudience.MicrosoftGraph:
152152
if (!string.IsNullOrEmpty(Tenant))
@@ -181,7 +181,7 @@ internal GenericToken TryGetToken(TokenAudience tokenAudience, string[] roles =
181181
return null;
182182
}
183183

184-
if(token != null)
184+
if (token != null)
185185
{
186186
// Managed to create a token for the requested audience, add it to our collection with tokens
187187
AccessTokens[tokenAudience] = token;
@@ -224,29 +224,29 @@ internal void ClearTokens()
224224
/// <param name="minimalHealthScore">Minimum health score that the SharePoint server should report before allowing requests to be executed on it. Scale of 0 to 10 where 0 is healthiest and 10 is least healthy. Leave NULL not to perform health checks on SharePoint.</param>
225225
/// <param name="pnpVersionTag">Identifier set on the SharePoint ClientContext as the ClientTag to identify the source of the requests to SharePoint. Leave NULL not to set it.</param>
226226
/// <param name="disableTelemetry">Boolean indicating if telemetry on the commands being executed should be disabled. Telemetry is enabled by default.</param>
227-
private PnPConnection(PSHost host,
228-
InitializationType initializationType,
229-
string url = null,
230-
ClientContext clientContext = null,
227+
private PnPConnection(PSHost host,
228+
InitializationType initializationType,
229+
string url = null,
230+
ClientContext clientContext = null,
231231
Dictionary<TokenAudience, GenericToken> tokens = null,
232232
int? minimalHealthScore = null,
233-
string pnpVersionTag = null,
233+
string pnpVersionTag = null,
234234
bool disableTelemetry = false)
235235
{
236236
if (!disableTelemetry)
237237
{
238238
InitializeTelemetry(clientContext, host, initializationType);
239239
}
240240

241-
UserAgent = $"NONISV|SharePointPnP|PnPPS/{((AssemblyFileVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttribute(typeof(AssemblyFileVersionAttribute))).Version}";
241+
UserAgent = $"NONISV|SharePointPnP|PnPPS/{((AssemblyFileVersionAttribute)Assembly.GetExecutingAssembly().GetCustomAttribute(typeof(AssemblyFileVersionAttribute))).Version}";
242242
Context = clientContext;
243243

244244
// Enrich the AccessTokens collection with the token(s) passed in
245245
if (tokens != null)
246246
{
247247
AccessTokens.AddRange(tokens);
248248
}
249-
249+
250250
// Validate if we have a SharePoint Context
251251
if (Context != null)
252252
{
@@ -295,7 +295,7 @@ private PnPConnection(PSHost host,
295295
/// <param name="pnpVersionTag">Identifier set on the SharePoint ClientContext as the ClientTag to identify the source of the requests to SharePoint. Leave NULL not to set it.</param>
296296
/// <param name="disableTelemetry">Boolean indicating if telemetry on the commands being executed should be disabled. Telemetry is enabled by default.</param>
297297
/// <returns><see cref="PnPConnection"/ instance which can be used to communicate with one of the supported APIs</returns>
298-
public static PnPConnection GetConnectionWithClientIdAndClientSecret(string clientId,
298+
public static PnPConnection GetConnectionWithClientIdAndClientSecret(string clientId,
299299
string clientSecret,
300300
PSHost host,
301301
InitializationType initializationType,
@@ -329,7 +329,7 @@ public static PnPConnection GetConnectionWithClientIdAndClientSecret(string clie
329329
/// <param name="pnpVersionTag">Identifier set on the SharePoint ClientContext as the ClientTag to identify the source of the requests to SharePoint. Leave NULL not to set it.</param>
330330
/// <param name="disableTelemetry">Boolean indicating if telemetry on the commands being executed should be disabled. Telemetry is enabled by default.</param>
331331
/// <returns><see cref="PnPConnection"/ instance which can be used to communicate with one of the supported APIs</returns>
332-
public static PnPConnection GetConnectionWithClientIdAndCertificate(string clientId,
332+
public static PnPConnection GetConnectionWithClientIdAndCertificate(string clientId,
333333
X509Certificate2 certificate,
334334
PSHost host,
335335
InitializationType initializationType,
@@ -364,7 +364,7 @@ public static PnPConnection GetConnectionWithClientIdAndCertificate(string clien
364364
public static PnPConnection GetConnectionWithPsCredential(PSCredential credential,
365365
PSHost host,
366366
InitializationType initializationType,
367-
string url = null,
367+
string url = null,
368368
ClientContext clientContext = null,
369369
int? minimalHealthScore = null,
370370
string pnpVersionTag = null,
@@ -419,17 +419,17 @@ internal PnPConnection(ClientContext context, ConnectionType connectionType, int
419419
ClientSecret = clientSecret;
420420
}
421421

422-
internal PnPConnection(ClientContext context,
423-
ConnectionType connectionType,
424-
int minimalHealthScore,
425-
int retryCount,
426-
int retryWait,
427-
PSCredential credential,
428-
string url,
429-
string tenantAdminUrl,
430-
string pnpVersionTag,
431-
PSHost host,
432-
bool disableTelemetry,
422+
internal PnPConnection(ClientContext context,
423+
ConnectionType connectionType,
424+
int minimalHealthScore,
425+
int retryCount,
426+
int retryWait,
427+
PSCredential credential,
428+
string url,
429+
string tenantAdminUrl,
430+
string pnpVersionTag,
431+
PSHost host,
432+
bool disableTelemetry,
433433
InitializationType initializationType)
434434
{
435435
if (!disableTelemetry)
@@ -442,7 +442,7 @@ internal PnPConnection(ClientContext context,
442442
// throw new ArgumentNullException(nameof(context));
443443
Context = context;
444444
Context.ExecutingWebRequest += Context_ExecutingWebRequest;
445-
445+
446446
ConnectionType = connectionType;
447447
MinimalHealthScore = minimalHealthScore;
448448
RetryCount = retryCount;
@@ -478,10 +478,12 @@ internal PnPConnection(ClientContext context, GenericToken tokenResult, Connecti
478478
PnPVersionTag = pnpVersionTag;
479479
Url = (new Uri(url)).AbsoluteUri;
480480
ConnectionMethod = ConnectionMethod.AccessToken;
481+
ClientId = DeviceLoginClientId;
482+
Tenant = tokenResult.ParsedToken.Claims.FirstOrDefault(c => c.Type == "tid").Value;
481483
context.ExecutingWebRequest += (sender, args) =>
482484
{
483485
args.WebRequestExecutor.WebRequest.UserAgent = UserAgent;
484-
args.WebRequestExecutor.RequestHeaders["Authorization"] = "Bearer " + CurrentConnection.TryGetAccessToken(TokenAudience.MicrosoftGraph);
486+
args.WebRequestExecutor.RequestHeaders["Authorization"] = "Bearer " + tokenResult.AccessToken;
485487
};
486488
}
487489

@@ -552,7 +554,7 @@ internal ClientContext CloneContext(string url)
552554
if ((ex is WebException || ex is NotSupportedException) && CurrentConnection.PSCredential != null)
553555
{
554556
// legacy auth?
555-
using(var authManager = new OfficeDevPnP.Core.AuthenticationManager())
557+
using (var authManager = new OfficeDevPnP.Core.AuthenticationManager())
556558
{
557559
context = authManager.GetAzureADCredentialsContext(url.ToString(), CurrentConnection.PSCredential.UserName, CurrentConnection.PSCredential.Password);
558560
}

Commands/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
// You can specify all the values or you can default the Build and Revision Numbers
4949
// by using the '*' as shown below:
5050
// [assembly: AssemblyVersion("1.0.*")]
51-
[assembly: AssemblyVersion("3.22.2006.1")]
52-
[assembly: AssemblyFileVersion("3.22.2006.1")]
51+
[assembly: AssemblyVersion("3.22.2006.2")]
52+
[assembly: AssemblyFileVersion("3.22.2006.2")]
5353
[assembly: InternalsVisibleTo("SharePointPnP.PowerShell.Tests")]

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.22.2006.1
1+
3.22.2006.2

0 commit comments

Comments
 (0)