-
Notifications
You must be signed in to change notification settings - Fork 317
API | AccessTokenCallback support #1260
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
Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
b974ffb
POC for TokenCredential support
christothes 8f76542
POC 2 - callback abstraction
christothes 7ffc10c
merge
christothes 9ed36d7
POC 3
christothes 8321090
fix
christothes 2aee2b2
Merge remote-tracking branch 'upstream/main' into chriss/ADCreds
christothes ea47be2
Merge remote-tracking branch 'upstream/main' into chriss/ADCreds
christothes 10f5a95
merge
christothes d281983
cleanups
christothes fcfb66e
formatting
christothes 4c718b5
netfx consistency
christothes 4ccc412
fix
christothes 68bf511
cleanup
christothes 0671d58
merge
christothes d9570b3
nuget
christothes aa517b6
source ref
christothes c5def10
revert nuget.config change
christothes 727406f
Update src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlCli…
christothes 5c1b5ef
cast timeout to int
christothes d82f3bb
PR feedback
christothes 9a9cd87
tests
christothes 677f729
fix resources
christothes afc5fff
fix error messages for fx
christothes 2673bd4
fixes
christothes b08a251
rename AzureADTokenRequestContext
christothes be1263e
use SqlAuthenticationParameters in callback
christothes 52a84f9
docs and simple sample
christothes 9be9391
tests for password and userId with callback
christothes a2233f5
add to SqlClient.cs API listing
christothes c1df1f4
Allow credential with callback and pass to the callback, if available
David-Engel a4aca8f
Merge pull request #1 from David-Engel/ADCreds
christothes fc57e98
Merge remote-tracking branch 'upstream/main' into chriss/ADCreds
DavoudEshtehari 2ab55b8
fb
christothes ada78c2
Apply suggestions from code review
christothes 1e531dc
Merge branch 'chriss/ADCreds' of https://github.com/christothes/SqlCl…
christothes caa6c3e
fb
christothes 36a59e8
Apply suggestions from code review
christothes cd922db
Merge branch 'chriss/ADCreds' of https://github.com/christothes/SqlCl…
christothes 16693f6
fb
christothes 78b9e4a
fb
christothes 67bfd01
Add tests
DavoudEshtehari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System; | ||
| using System.Data; | ||
| // <Snippet1> | ||
| using Microsoft.Data.SqlClient; | ||
| using Azure.Identity; | ||
|
|
||
| class Program | ||
| { | ||
| static void Main() | ||
| { | ||
| OpenSqlConnection(); | ||
| Console.ReadLine(); | ||
| } | ||
|
|
||
| private static void OpenSqlConnection() | ||
| { | ||
| string connectionString = GetConnectionString(); | ||
| using (SqlConnection connection = new SqlConnection("Data Source=contoso.database.windows.net;Initial Catalog=AdventureWorks;") | ||
| { | ||
| AccessTokenCallback = async (authParams, cancellationToken) => | ||
| { | ||
| var cred = new DefaultAzureCredential(); | ||
| string scope = authParams.Resource.EndsWith(s_defaultScopeSuffix) ? authParams.Resource : authParams.Resource + s_defaultScopeSuffix; | ||
| var token = await cred.GetTokenAsync(new TokenRequestContext(new[] { scope }), cancellationToken); | ||
| return new SqlAuthenticationToken(token.Token, token.ExpiresOn); | ||
| } | ||
| }) | ||
| { | ||
| connection.Open(); | ||
| Console.WriteLine("ServerVersion: {0}", connection.ServerVersion); | ||
| Console.WriteLine("State: {0}", connection.State); | ||
| } | ||
| } | ||
| } | ||
| // </Snippet1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.