Created
December 28, 2013 20:52
-
-
Save ctaggart/8164083 to your computer and use it in GitHub Desktop.
How do I get the Visual Studio Online credentials cached in the registry? http://stackoverflow.com/questions/20809207/how-do-i-get-the-visual-studio-online-credentials-cached-in-the-registry
This file contains 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
#r "Microsoft.TeamFoundation.Client" | |
#r "Microsoft.VisualStudio.Services.Common" | |
#r "System.Net.Http" | |
open System | |
open Microsoft.TeamFoundation.Client | |
// retrieve VssToken | |
// for the logged in user "IdeUser" | |
let vssTokenIdeUser = TfsClientCredentialStorage.RetrieveConnectedUserToken() | |
let tokenStorage = Microsoft.VisualStudio.Services.Common.TokenStorage.VssTokenStorageFactory.GetTokenStorageNamespace "VisualStudio" | |
let vssTokens = tokenStorage.RetrieveAll "VssApp" |> Array.ofSeq | |
for t in vssTokens do | |
printfn "%s %s %s %s" t.Resource t.Type (t.GetProperty "UserId") (t.GetProperty "UserName") | |
// create a TfsClientCredentials by retrieving an IssuedToken | |
let ccs = TfsClientCredentialStorage() | |
let ct = ccs.RetrieveToken(Uri "https://ctaggart.visualstudio.com", Microsoft.VisualStudio.Services.Common.VssCredentialsType.Federated) :?> CookieToken | |
let cc = CookieCredential(false, ct) | |
let tcc = TfsClientCredentials cc | |
// use the TfsClientCredentials to authenticate with | |
let tfs = new TfsTeamProjectCollection(Uri "https://ctaggart.visualstudio.com/DefaultCollection", tcc) | |
tfs.Authenticate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interesting.
One question, what package you downloaded to use "Microsoft.VisualStudio" namespace.
I'm not found this, can you help me ?