6. Your
Client App
Microsoft Account
Outlook.com
Your
Client App
Azure AD
Exchange Online
Your
Client App
Unified AuthN/Z endpoint
(https://login.microsoftonline.com/common/oauth2/v2.0)
Unified API endpoint
(OneDrive, Outlook, etc)
v2.0 endpoint
Microsoft Graph
18. // get Microsoft Web Account Manager Provider
var provider =
await WebAuthenticationCoreManager.FindAccountProviderAsync(
"https://login.microsoft.com", "organizations");
// request result token to Web Account Manager
WebTokenRequest webTokenRequest = new WebTokenRequest(
provider, "", "553bd5ae-0b5c-40b3-abeb-4ffa34eca2d3");
webTokenRequest.Properties.Add(
"resource", "https://graph.windows.net");
WebTokenRequestResult webTokenResult =
await WebAuthenticationCoreManager.RequestTokenAsync(
webTokenRequest);
// retrieve access token
// webTokenResult.ResponseData[0].Token に入っている
20. // Create the credential
KeyCredentialRetrievalResult createRes =
await KeyCredentialManager.RequestCreateAsync("key1",
KeyCredentialCreationOption.ReplaceExisting);
// if the status is success, retrieve the public key.
var pubKey = createRes.Credential.RetrievePublicKey();
// convert string to binary buffer
var inputbuf = CryptographicBuffer.ConvertStringToBinary(
"Test Data 1", BinaryStringEncoding.Utf8);
// sign using retrieved private key
KeyCredentialOperationResult signRes =
await res.Credential.RequestSignAsync(inputbuf);
// get the base64 encoded data to cryptographically sign
string base64encSignature =
CryptographicBuffer.EncodeToBase64String(signRes.Result);