Skip to content
Open
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

Large diffs are not rendered by default.

1,185 changes: 604 additions & 581 deletions Reference-Architecture/Client/MixedReality-Azure-Unity/Assembly-CSharp.csproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Assets.MixedRealityAzure.AzureAD.Models;
using Microsoft.MR;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Http;
using UnityEngine;

public class AzureAuthentication
: MonoBehaviour
{
[Tooltip("The application ID from Azure AD.")]
[SecretValue("AAD.ClientId")]
public string ClientId;

[Tooltip("The client secret for the application.")]
[SecretValue("AAD.ClientSecret")]
public string ClientSecret;

[Tooltip("The tenant ID for AAD.")]
[SecretValue("AAD.TenantId")]
public string TenantId;

[Tooltip("The resource name like https://graph.microsoft.com.")]
[SecretValue("AAD.Resource")]
public string Resource;

[Tooltip("The user's Username.")]
[SecretValue("AAD.Username")]
public string Username;

[Tooltip("The user's password.")]
[SecretValue("AAD.Password")]
public string Password;

// Use this for initialization
void Start()
{
StartCoroutine(Authenticate((identityResult) =>
{
// Update UI here...

// Call out to other service using identityResult.access_token
}));
}

IEnumerator Authenticate(Action<IdentityResult> identityCallback)
{
var grantType = "password";
var scope = "openid";

var formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("resource", Resource),
new KeyValuePair<string, string>("client_id", ClientId),
new KeyValuePair<string, string>("client_secret", ClientSecret),
new KeyValuePair<string, string>("grant_type", grantType),
new KeyValuePair<string, string>("username", Username),
new KeyValuePair<string, string>("password", Password),
new KeyValuePair<string, string>("scope", scope),
});

var httpClient = new HttpClient();
var httpResponseMessageTask = httpClient.PostAsync($"https://login.windows.net/{TenantId}/oauth2/token", formContent);
var jsonTask = httpResponseMessageTask.Result.Content.ReadAsStringAsync();

// Below doesn't work because their deserializer expects numbers to be 3 instead of "3"...
//var identityResult = JsonUtility.FromJson<IdentityResult>(jsonTask.Result);
var identityResult = JsonConvert.DeserializeObject<IdentityResult>(jsonTask.Result);

yield return new WaitUntil(() => true);

identityCallback(identityResult);
}

// Update is called once per frame
void Update()
{

}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Assets.MixedRealityAzure.AzureAD.Models
{
public class IdentityResult
{
public string token_type { get; set; }
public string scope { get; set; }
public string expires_in { get; set; }
public string ext_expires_in { get; set; }
public string expires_on { get; set; }
public string not_before { get; set; }
public string resource { get; set; }
public string access_token { get; set; }
public string refresh_token { get; set; }
public string id_token { get; set; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MixedReality-Azure-Unity", "MixedReality-Azure-Unity.csproj", "{4440C6AA-B958-1E90-8BF6-9741696C9C4A}"
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MixedReality-Azure-Unity", "Assembly-CSharp.csproj", "{6208DB9F-F8AC-EBCB-7B18-67F4C4065086}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.PackageManagerUI.Editor", "Unity.PackageManagerUI.Editor.csproj", "{6877705C-FBD9-0C4F-5AFB-6FB431E5D39D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MixedReality-Azure-Unity.Editor", "MixedReality-Azure-Unity.Editor.csproj", "{A7775F69-050F-CC87-3441-23EDC710AFFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityEditor.StandardEvents", "UnityEditor.StandardEvents.csproj", "{6800202F-4402-D405-F8CB-03DC7BD78B92}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MixedReality-Azure-Unity", "Assembly-CSharp-Editor.csproj", "{EDA4797C-B86C-95C4-91A7-0692260042EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4440C6AA-B958-1E90-8BF6-9741696C9C4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4440C6AA-B958-1E90-8BF6-9741696C9C4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4440C6AA-B958-1E90-8BF6-9741696C9C4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4440C6AA-B958-1E90-8BF6-9741696C9C4A}.Release|Any CPU.Build.0 = Release|Any CPU
{6877705C-FBD9-0C4F-5AFB-6FB431E5D39D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6877705C-FBD9-0C4F-5AFB-6FB431E5D39D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6877705C-FBD9-0C4F-5AFB-6FB431E5D39D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6877705C-FBD9-0C4F-5AFB-6FB431E5D39D}.Release|Any CPU.Build.0 = Release|Any CPU
{A7775F69-050F-CC87-3441-23EDC710AFFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7775F69-050F-CC87-3441-23EDC710AFFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7775F69-050F-CC87-3441-23EDC710AFFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7775F69-050F-CC87-3441-23EDC710AFFA}.Release|Any CPU.Build.0 = Release|Any CPU
{6800202F-4402-D405-F8CB-03DC7BD78B92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6800202F-4402-D405-F8CB-03DC7BD78B92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6800202F-4402-D405-F8CB-03DC7BD78B92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6800202F-4402-D405-F8CB-03DC7BD78B92}.Release|Any CPU.Build.0 = Release|Any CPU
{6208DB9F-F8AC-EBCB-7B18-67F4C4065086}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6208DB9F-F8AC-EBCB-7B18-67F4C4065086}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6208DB9F-F8AC-EBCB-7B18-67F4C4065086}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6208DB9F-F8AC-EBCB-7B18-67F4C4065086}.Release|Any CPU.Build.0 = Release|Any CPU
{EDA4797C-B86C-95C4-91A7-0692260042EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDA4797C-B86C-95C4-91A7-0692260042EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDA4797C-B86C-95C4-91A7-0692260042EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDA4797C-B86C-95C4-91A7-0692260042EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
m_EditorVersion: 2018.1.0f2
m_EditorVersion: 2018.2.0x-ImprovedPrefabs
Loading