diff options
Diffstat (limited to 'samples/OAuthClient/AzureAD.aspx.cs')
-rw-r--r-- | samples/OAuthClient/AzureAD.aspx.cs | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/samples/OAuthClient/AzureAD.aspx.cs b/samples/OAuthClient/AzureAD.aspx.cs index 4b601fd..e392725 100644 --- a/samples/OAuthClient/AzureAD.aspx.cs +++ b/samples/OAuthClient/AzureAD.aspx.cs @@ -1,5 +1,4 @@ -namespace OAuthClient -{ +namespace OAuthClient { using System; using System.Configuration; using System.Net; @@ -11,23 +10,18 @@ using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2; - public partial class AzureAD : System.Web.UI.Page - { - private static readonly AzureADClient client = new AzureADClient - { + public partial class AzureAD : System.Web.UI.Page { + private static readonly AzureADClient client = new AzureADClient { ClientIdentifier = ConfigurationManager.AppSettings["AzureADAppID"], ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(ConfigurationManager.AppSettings["AzureADAppSecret"]), }; - protected void Page_Load(object sender, EventArgs e) - { + + protected void Page_Load(object sender, EventArgs e) { IAuthorizationState authorization = client.ProcessUserAuthorization(); - if (authorization == null) - { + if (authorization == null) { // Kick off authorization request client.RequestUserAuthorization(); - } - else - { + } else { string token = authorization.AccessToken; AzureADClaims claimsAD = client.ParseAccessToken(token); @@ -35,10 +29,8 @@ var request = WebRequest.Create("https://graph.windows.net/" + claimsAD.Tid + "/users/" + claimsAD.Oid + "?api-version=0.9"); request.Headers = new WebHeaderCollection(); request.Headers.Add("authorization", token); - using (var response = request.GetResponse()) - { - using (var responseStream = response.GetResponseStream()) - { + using (var response = request.GetResponse()) { + using (var responseStream = response.GetResponseStream()) { var serializer = new DataContractJsonSerializer(typeof(AzureADGraph)); AzureADGraph graphData = (AzureADGraph)serializer.ReadObject(responseStream); this.nameLabel.Text = HttpUtility.HtmlEncode(graphData.DisplayName); |