Skip to content
Permalink
Browse files

new code

  • Loading branch information...
spelluru committed May 5, 2017
1 parent 68931be commit d8cb67afc82e2f52bfd1027208f2f901a735a287
Showing with 36 additions and 14 deletions.
  1. +7 −7 Get started creating a Data Catalog app.csproj
  2. +21 −0 LICENSE.txt
  3. +7 −6 Program.cs
  4. +1 −1 packages.config
@@ -33,13 +33,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.13.9\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform">
<HintPath>packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.13.9\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json.dll">
<HintPath>packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -55,7 +53,9 @@
<ItemGroup>
<None Include="App.config" />
<None Include="CONTRIBUTING.md" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -5,6 +5,7 @@
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Net;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace ConsoleApplication
@@ -47,7 +48,7 @@ static void Main(string[] args)

Console.WriteLine("Delete data asset. Press Enter to continue");

DeleteDataAsset(id, item["etag"].ToString());
DeleteDataAsset(id);

Console.ReadLine();
}
@@ -57,7 +58,7 @@ static void Main(string[] args)
// AuthenticationContext is part of the Active Directory Authentication Library NuGet package
// To install the Active Directory Authentication Library NuGet package in Visual Studio,
// run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the NuGet Package Manager Console.
static AuthenticationResult AccessToken()
static async Task<AuthenticationResult> AccessToken()
{
if (authResult == null)
{
@@ -78,7 +79,7 @@ static AuthenticationResult AccessToken()

// Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint
// AcquireToken takes a Client Id that Azure AD creates when you register your client app.
authResult = authContext.AcquireToken(resourceUri, clientId, new Uri(redirectUri), PromptBehavior.RefreshSession);
authResult = await authContext.AcquireTokenAsync(resourceUri, clientId, new Uri(redirectUri), new PlatformParameters(PromptBehavior.Always));
}

return authResult;
@@ -97,7 +98,7 @@ static string RegisterDataAsset(string json)
HttpWebRequest request = System.Net.WebRequest.Create(fullUri) as System.Net.HttpWebRequest;
request.KeepAlive = true;
request.Method = "POST";

try
{
var response = SetRequestAndGetResponse(request, json);
@@ -280,7 +281,7 @@ static HttpWebResponse SetRequestAndGetResponse(HttpWebRequest request, string p
while (true)
{
//To authorize the operation call, you need an access token which is part of the Authorization header
request.Headers.Add("Authorization", AccessToken().CreateAuthorizationHeader());
request.Headers.Add("Authorization", AccessToken().Result.CreateAuthorizationHeader());
//Set to false to be able to intercept redirects
request.AllowAutoRedirect = false;

@@ -331,7 +332,7 @@ static string SampleJson(string name)
""protocol"": ""tds"",
""authentication"": ""windows"",
""address"": {{
""server"": ""MyServer.contoso.com"",
""server"": ""test.contoso.com"",
""database"": ""Northwind"",
""schema"": ""dbo"",
""object"": ""{0}""
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.21.301221612" targetFramework="net451" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.13.9" targetFramework="net451" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
</packages>

0 comments on commit d8cb67a

Please sign in to comment.
You can’t perform that action at this time.