public async Task SilentAuthenticateWithBrokerAsync() { TokenCachePersistenceOptions persistenceOptions = new TokenCachePersistenceOptions(); // to fully manually verify the InteractiveBrowserCredential this test should be run both authenticating with a // school / organization account as well as a personal live account, i.e. a @outlook.com, @live.com, or @hotmail.com var cred = new InteractiveBrowserCredential(new InteractiveBrowserCredentialBrokerOptions { TokenCachePersistenceOptions = persistenceOptions }); AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false); Assert.NotNull(token.Token); var silentCred = new SharedTokenCacheCredential(new SharedTokenCacheCredentialBrokerOptions()); // The calls below this should be silent and not require user interaction token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false); Assert.NotNull(token.Token); token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://management.core.windows.net//.default" })).ConfigureAwait(false); Assert.NotNull(token.Token); }
public SharedTokenCacheProvider(byte[] adalTokenCache = null) { AdalTokenCache = adalTokenCache; TokenCachePersistenceOptions = new TokenCachePersistenceOptions() { UnsafeAllowUnencryptedStorage = true }; }
public void VerifyTokenCacheOptionsCtorParam() { // verify passed in TokenCachePeristenceOptions are honored var persistenceOptions = new TokenCachePersistenceOptions { Name = "mocktokencachename" }; var credentialOptions = new SharedTokenCacheCredentialBrokerOptions(persistenceOptions); Assert.AreEqual(persistenceOptions, credentialOptions.TokenCachePersistenceOptions); }
public void Identity_TokenCache_PersistentUnencrypted() { #region Snippet:Identity_TokenCache_PersistentUnencrypted var persistenceOptions = new TokenCachePersistenceOptions { UnsafeAllowUnencryptedStorage = true }; var credential = new InteractiveBrowserCredential( new InteractiveBrowserCredentialOptions { TokenCachePersistenceOptions = persistenceOptions } ); #endregion }
public void Identity_TokenCache_PersistentNamed() { #region Snippet:Identity_TokenCache_PersistentNamed var persistenceOptions = new TokenCachePersistenceOptions { Name = "my_application_name" }; var credential = new InteractiveBrowserCredential( new InteractiveBrowserCredentialOptions { TokenCachePersistenceOptions = persistenceOptions } ); #endregion }
public void VerifyCachePersistenceOptionsCtorParam() { // verify passed in TokenCachePeristenceOptions are honored var persistenceOptions = new TokenCachePersistenceOptions { Name = "mocktokencachename" }; var credentialOptions = new SharedTokenCacheCredentialOptions(persistenceOptions); Assert.AreEqual(persistenceOptions, credentialOptions.TokenCachePersistenceOptions); // verify passing null uses the default token cache persistence settings credentialOptions = new SharedTokenCacheCredentialOptions(null); Assert.AreEqual(SharedTokenCacheCredentialOptions.s_defaulTokenCachetPersistenceOptions, credentialOptions.TokenCachePersistenceOptions); // verify calling the default constructor uses the default token cache persistence settings credentialOptions = new SharedTokenCacheCredentialOptions(); Assert.AreEqual(SharedTokenCacheCredentialOptions.s_defaulTokenCachetPersistenceOptions, credentialOptions.TokenCachePersistenceOptions); }
/// <summary> /// Initializes a new instance of <see cref="SharedTokenCacheCredentialBrokerOptions"/>. /// </summary> /// <param name="tokenCacheOptions">The <see cref="TokenCachePersistenceOptions"/> that will apply to the token cache used by this credential.</param> public SharedTokenCacheCredentialBrokerOptions(TokenCachePersistenceOptions tokenCacheOptions) : base(tokenCacheOptions) { }
public void CtorAllowsAllPermutations(TokenCachePersistenceOptions options, bool expectedAllowUnencryptedStorage, string expectedName) { cache = new TokenCache(options); }
/// <summary> /// Initializes a new instance of <see cref="SharedTokenCacheCredentialOptions"/>. /// </summary> /// <param name="tokenCacheOptions">The <see cref="TokenCachePersistenceOptions"/> that will apply to the token cache used by this credential.</param> public SharedTokenCacheCredentialOptions(TokenCachePersistenceOptions tokenCacheOptions) { // if no tokenCacheOptions were specified we should use the default shared token cache TokenCachePersistenceOptions = tokenCacheOptions ?? s_defaulTokenCachetPersistenceOptions; }
/// <summary> /// Initializes a new instance of <see cref="SharedTokenCacheCredentialOptions"/>. /// </summary> /// <param name="tokenCacheOptions">The <see cref="TokenCachePersistenceOptions"/> that will apply to the token cache used by this credential.</param> public SharedTokenCacheCredentialOptions(TokenCachePersistenceOptions tokenCacheOptions) { TokenCachePersistenceOptions = tokenCacheOptions; }