Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion Commands/Admin/SetTenant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace SharePointPnP.PowerShell.Commands.Admin
Code = @"PS:> Set-PnPTenant -ShowAllUsersClaim $false",
Remarks = @"This example hides the ""All Users"" claim group in People Picker.", SortOrder = 3)]
[CmdletExample(
Code = @"PS:> Set-SPOTenant -UsePersistentCookiesForExplorerView $true",
Code = @"PS:> Set-PnPTenant -UsePersistentCookiesForExplorerView $true",
Remarks = @"This example enables the use of special persisted cookie for Open with Explorer.", SortOrder = 3)]
public class SetTenant : PnPAdminCmdlet
{
Expand Down
2 changes: 1 addition & 1 deletion Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public class ConnectOnline : PSCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_GRAPHDEVICELOGIN, HelpMessage = "Launch a browser automatically and copy the code to enter to the clipboard")]
public SwitchParameter LaunchBrowser;

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_GRAPHDEVICELOGIN, HelpMessage = @"Log in using the PnP O365 Management Shell application towards the Graph. You will be asked to consent to:
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_GRAPHDEVICELOGIN, HelpMessage = @"Log in using the PnP O365 Management Shell application towards the Graph. You will be asked to consent to:

* Read and write managed metadata
* Have full control of all site collections
Expand Down
1 change: 1 addition & 0 deletions Commands/Base/DisconnectSPOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected override void ProcessRecord()

internal static bool DisconnectCurrentService(SPOnlineConnection connection)
{
SPOnlineConnection.CurrentConnection.AccessToken = string.Empty;
if (connection == null)
return false;
connection = null;
Expand Down
26 changes: 22 additions & 4 deletions Commands/Base/PnPGraphCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ public String AccessToken

protected override void BeginProcessing()
{

base.BeginProcessing();

if (SPOnlineConnection.CurrentConnection != null && SPOnlineConnection.CurrentConnection.ConnectionMethod == Model.ConnectionMethod.GraphDeviceLogin)

#if !NETSTANDARD2_0

if (SPOnlineConnection.CurrentConnection != null && SPOnlineConnection.CurrentConnection.ConnectionMethod == Model.ConnectionMethod.GraphDeviceLogin)
{
if (string.IsNullOrEmpty(SPOnlineConnection.CurrentConnection.AccessToken))
{
Expand All @@ -63,15 +66,30 @@ protected override void BeginProcessing()
else
{
if (SPOnlineConnection.AuthenticationResult == null ||
#if !NETSTANDARD2_0
String.IsNullOrEmpty(SPOnlineConnection.AuthenticationResult.Token))
{
throw new InvalidOperationException(Resources.NoAzureADAccessToken);
}
}
#else
if (SPOnlineConnection.CurrentConnection != null && SPOnlineConnection.CurrentConnection.ConnectionMethod == Model.ConnectionMethod.GraphDeviceLogin)
{
// Graph Connection
if (string.IsNullOrEmpty(SPOnlineConnection.CurrentConnection.AccessToken))
{
throw new InvalidOperationException(Resources.NoAzureADAccessToken);
}
}
else
{
//Normal connection
if (SPOnlineConnection.AuthenticationResult == null ||
string.IsNullOrEmpty(SPOnlineConnection.AuthenticationResult.AccessToken))
#endif
{
throw new InvalidOperationException(Resources.NoAzureADAccessToken);
}
}
#endif
}

protected virtual void ExecuteCmdlet()
Expand Down
13 changes: 13 additions & 0 deletions Commands/Base/SPOnlineConnectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,19 @@ internal static SPOnlineConnection InstantiateGraphDeviceLoginConnection(bool la
});
#else
OpenBrowser(returnData["verification_url"]);
messageCallback(returnData["message"]);

var tokenResult = GetTokenResult(connectionUri, returnData, messageCallback, progressCallback);

if (tokenResult != null)
{
progressCallback("Token received");
spoConnection = new SPOnlineConnection(tokenResult, ConnectionType.O365, minimalHealthScore, retryCount, retryWait, PnPPSVersionTag);
}
else
{
progressCallback("No token received.");
}
#endif
}
else
Expand Down
4 changes: 4 additions & 0 deletions Commands/Provisioning/ApplyProvisioningTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ protected override void ExecuteCmdlet()
{
Path = System.IO.Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, Path);
}
if(!System.IO.File.Exists(Path))
{
throw new FileNotFoundException($"File not found");
}
if (!string.IsNullOrEmpty(ResourceFolder))
{
if (!System.IO.Path.IsPathRooted(ResourceFolder))
Expand Down