Skip to content

SNOW-2169830 document MFA token caching #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-dszmolka
Copy link
Contributor

@sfc-gh-dszmolka sfc-gh-dszmolka commented Jul 16, 2025

Description

This came out of #1194 where it was an unnecessarily long struggle to setup MFA token caching, mostly due to how it is entirely undocumented.

This PR aims to change that.

Checklist

  • Code compiles correctly
  • Code is formatted according to Coding Conventions
  • Created tests which fail without the change (if possible)
  • All tests passing (dotnet test)
  • Extended the README / documentation, if necessary
  • Provide JIRA issue id (if possible) or GitHub issue id in PR name

@sfc-gh-dszmolka sfc-gh-dszmolka requested a review from a team as a code owner July 16, 2025 12:56
Copy link

codecov bot commented Jul 16, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3155 1 3154 108
View the top 3 failed test(s) by shortest run time
Snowflake.Data.Tests.UnitTests.Logger.EasyLoggerManagerTest::TestThatLogsToProperFileWithProperLogLevelOnly
Stack Traces | 0.013s run time
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
   at System.IO.ReadLinesIterator.CreateIterator(String path, Encoding encoding, StreamReader reader)
   at System.IO.ReadLinesIterator.Clone()
   at System.IO.Iterator`1.GetEnumerator()
   at System.IO.Iterator`1.System.Collections.IEnumerable.GetEnumerator()
   at NUnit.Framework.Constraints.ExactCountConstraint.ApplyTo[TActual](TActual actual)
   at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, String message, Object[] args)
   at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression)
   at Snowflake.Data.Tests.UnitTests.Logger.EasyLoggerManagerTest.TestThatLogsToProperFileWithProperLogLevelOnly() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\UnitTests\Logger\EasyLoggerManagerTest.cs:line 86
Snowflake.Data.Tests.IntegrationTests.ConnectionMultiplePoolsAsyncIT::TestMinPoolSizeAsync
Stack Traces | 0.204s run time
--TearDown
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Snowflake.Data.Core.RestRequester.Post[T](IRestRequest request) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\RestRequester.cs:line 51
   at Snowflake.Data.Core.SFSession.PostCloseSession(SFRestRequest closeSessionRequest, IRestRequester restRequester) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\Session\SFSession.cs:line 378
   at Snowflake.Data.Core.SFSession.close() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\Session\SFSession.cs:line 327
   at Snowflake.Data.Core.Session.SessionPool.ClearIdleSessions() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\Session\SessionPool.cs:line 629
   at Snowflake.Data.Core.Session.SessionPool.DestroyPool() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\Session\SessionPool.cs:line 591
   at Snowflake.Data.Core.Session.ConnectionPoolManager.ClearAllPools() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\Session\ConnectionPoolManager.cs:line 57
   at Snowflake.Data.Client.SnowflakeDbConnectionPool.SetConnectionPoolVersion(ConnectionPoolType requestedPoolType, Boolean force) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Client\SnowflakeDbConnectionPool.cs:line 138
   at Snowflake.Data.Client.SnowflakeDbConnectionPool.ForceConnectionPoolVersion(ConnectionPoolType requestedPoolType) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Client\SnowflakeDbConnectionPool.cs:line 154
   at Snowflake.Data.Tests.Util.PoolConfig.Reset() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\Util\PoolConfig.cs:line 24
   at Snowflake.Data.Tests.IntegrationTests.ConnectionMultiplePoolsAsyncIT.AfterTest() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\ConnectionMultiplePoolsAsyncIT.cs:line 32
--HttpRequestException
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at Snowflake.Data.Core.RestRequester.<SendAsync>d__10.MoveNext() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\RestRequester.cs:line 145
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Snowflake.Data.Core.RestRequester.<SendAsync>d__9.MoveNext() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\RestRequester.cs:line 95
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Snowflake.Data.Core.RestRequester.<PostAsync>d__4`1.MoveNext() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\RestRequester.cs:line 56
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Snowflake.Data.Core.RestRequester.<>c__DisplayClass3_0`1.<<Post>b__0>d.MoveNext() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data\Core\RestRequester.cs:line 51
Snowflake.Data.Tests.IntegrationTests.SFPutGetTest::TestPutGetCommand("brotli",NAMED,"/TEST_PATH",True)
Stack Traces | 6.8s run time
at Snowflake.Data.Tests.IntegrationTests.SFPutGetTest.PutFile(SnowflakeDbConnection conn, String additionalAttribute, ResultStatus expectedStatus, Boolean encloseInSingleQuotes) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\SFPutGetTest.cs:line 685
   at Snowflake.Data.Tests.IntegrationTests.SFPutGetTest.TestPutGetCommand(String sourceFileCompressionType, StageType stageType, String stagePath, Boolean autoCompress) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\SFPutGetTest.cs:line 518

1)    at Snowflake.Data.Tests.IntegrationTests.SFPutGetTest.PutFile(SnowflakeDbConnection conn, String additionalAttribute, ResultStatus expectedStatus, Boolean encloseInSingleQuotes) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\SFPutGetTest.cs:line 685
   at Snowflake.Data.Tests.IntegrationTests.SFPutGetTest.TestPutGetCommand(String sourceFileCompressionType, StageType stageType, String stagePath, Boolean autoCompress) in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\SFPutGetTest.cs:line 518

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@sfc-gh-dszmolka sfc-gh-dszmolka changed the title SNOW-2169830 document MFA token caching, and add the relevant param to session properties SNOW-2169830 document MFA token caching Jul 17, 2025
@sfc-gh-dszmolka sfc-gh-dszmolka requested a review from a team July 17, 2025 17:32
@sfc-gh-dszmolka sfc-gh-dszmolka enabled auto-merge (squash) July 17, 2025 17:32
- **Linux**: false
- **Mac**: false
#### Client Side
The **SSO token cache** and the token cache for **OAuth** authorization code flow and OAuth client credentials flow is enabled by setting the parameter `client_store_temporary_credential` to `true`. The default value is based on OS:
Copy link
Collaborator

@sfc-gh-pbulawa sfc-gh-pbulawa Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client credentials flow does not have the caching.

Suggested change
The **SSO token cache** and the token cache for **OAuth** authorization code flow and OAuth client credentials flow is enabled by setting the parameter `client_store_temporary_credential` to `true`. The default value is based on OS:
The **SSO token cache** and the token cache for **OAuth** authorization code flow is enabled by setting the parameter `client_store_temporary_credential` to `true`. The default value is based on OS:

Copy link
Collaborator

@sfc-gh-pbulawa sfc-gh-pbulawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client credentials flow does not have the caching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants