Skip to content

Commit

Permalink
Merge pull request #26 from bpendharkar/RedirectionHandler
Browse files Browse the repository at this point in the history
Add logic to navigate to redirection uris using PSCredential objects
  • Loading branch information
rgmills authored Feb 16, 2017
2 parents 90df614 + 2a74fa7 commit cddfb5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions ShareFileSnapIn/SendSfRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public class SendSfRequest : PSCmdlet
[Parameter]
public string Account { get; set; }

[Parameter]
public bool Redirect { get; set; }

[Parameter]
public PSCredential Credential { get; set; }

protected override void ProcessRecord()
{
if (Id != null && Uri != null) throw new Exception("Set only Id or Uri");
Expand All @@ -78,6 +84,18 @@ protected override void ProcessRecord()
if (Method == null) Method = "GET";
Method = Method.ToUpper();

if (Redirect)
{
if (Credential != null)
{
Client.Client.AddCredentials(Uri, "Basic", Credential.GetNetworkCredential());
}
else
{
throw new Exception("Parameter 'Credential' missing for a redirection uri.");
}
}

Query<ODataObject> query = new Query<ODataObject>(Client.Client);
query.HttpMethod = Method;

Expand Down
2 changes: 1 addition & 1 deletion ShareFileSnapIn/ShareFileSnapIn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<HintPath>..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="ShareFile.Api.Client, Version=3.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ShareFile.Api.Client.3.3.1476\lib\net45\ShareFile.Api.Client.dll</HintPath>
<HintPath>..\packages\ShareFile.Api.Client.3.3.1597\lib\net45\ShareFile.Api.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion ShareFileSnapIn/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
<package id="NLog" version="3.1.0.0" targetFramework="net451" />
<package id="ShareFile.Api.Client" version="3.3.1476" targetFramework="net45" />
<package id="ShareFile.Api.Client" version="3.3.1597" targetFramework="net451" />
<package id="System.Management.Automation" version="6.1.7601.17515" targetFramework="net45" />
</packages>

0 comments on commit cddfb5f

Please sign in to comment.