public async Task <bool> SignInAad() { var result = await GetAadTokenForUserAsync(CCSResource); if (result.TokenRequestStatus == ConnectedDevicesAccessTokenRequestStatus.Success) { SignedInAccount = new ConnectedDevicesUserAccount(Guid.NewGuid().ToString(), ConnectedDevicesUserAccountType.AAD); return(true); } return(false); }
public MicrosoftAccountProvider() { if (ApplicationData.Current.LocalSettings.Values.ContainsKey(MsaTokenKey)) { MsaToken = ApplicationData.Current.LocalSettings.Values[MsaTokenKey] as string; SignedInAccount = new ConnectedDevicesUserAccount(Guid.NewGuid().ToString(), ConnectedDevicesUserAccountType.MSA); } else { var authContext = new AuthenticationContext("https://login.microsoftonline.com/common"); if (authContext.TokenCache.Count > 0) { SignedInAccount = new ConnectedDevicesUserAccount(Guid.NewGuid().ToString(), ConnectedDevicesUserAccountType.AAD); } } }
public async Task <bool> SignInMsa() { string refreshToken = string.Empty; if (ApplicationData.Current.LocalSettings.Values.ContainsKey(MsaTokenKey)) { refreshToken = ApplicationData.Current.LocalSettings.Values[MsaTokenKey] as string; } if (string.IsNullOrEmpty(refreshToken)) { refreshToken = await MSAOAuthHelpers.GetRefreshTokenAsync(); } if (!string.IsNullOrEmpty(refreshToken)) { MsaToken = refreshToken; ApplicationData.Current.LocalSettings.Values[MsaTokenKey] = refreshToken; SignedInAccount = new ConnectedDevicesUserAccount(Guid.NewGuid().ToString(), ConnectedDevicesUserAccountType.MSA); return(true); } return(false); }