public AcrAccessToken(string username, string password, string scope, string loginUrl) { Scope = scope; authClient = new AzureContainerRegistryClient(new TokenCredentials(username, password)) { LoginUri = "https://" + loginUrl }; RefreshFn = () => { return(authClient.GetAccessTokenFromLoginAsync(loginUrl, scope).GetAwaiter().GetResult().AccessTokenProperty); }; Refresh(); }
public AcrAccessToken(AcrRefreshToken acrRefresh, string scope, string loginUrl) { Scope = scope; authClient = new AzureContainerRegistryClient(new TokenCredentials()) { LoginUri = "https://" + loginUrl }; RefreshFn = () => { acrRefresh.CheckAndRefresh(); return(authClient.GetAccessTokenAsync(loginUrl, scope, acrRefresh.Value).GetAwaiter().GetResult().AccessTokenProperty); }; Refresh(); }
public AcrRefreshToken(AuthToken aadToken, string loginUrl) { authClient = new AzureContainerRegistryClient(new TokenCredentials()) { LoginUri = "https://" + loginUrl }; RefreshFn = () => { // Note: should be using real new access token aadToken.CheckAndRefresh(); return(authClient.GetRefreshTokenFromExchangeAsync("access_token", loginUrl, "", null, aadToken.Value).GetAwaiter().GetResult().RefreshTokenProperty); }; Refresh(); }
/// <summary> /// Construct an ACR access token that refreshes from an ACR refresh token. /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="scope"></param> /// <param name="loginUrl"></param> public ContainerRegistryAccessToken(string username, string password, string scope, string loginUrl) { Scope = scope; authClient = new AzureContainerRegistryClient(new TokenCredentials(username, password)) { LoginUri = $"https://{loginUrl}" }; string tempRefreshFunction() { return(authClient.AccessTokens.GetFromLoginAsync(loginUrl, scope).GetAwaiter().GetResult().AccessTokenProperty); }; // initialize token and refresh function InitializeToken(tempRefreshFunction); }
/// <summary> /// Construct an ACR access token that refreshes from an ACR refresh token. /// </summary> /// <param name="acrRefresh"></param> /// <param name="scope"></param> /// <param name="loginUrl"></param> public ContainerRegistryAccessToken(ContainerRegistryRefreshToken refreshToken, string scope, string loginUrl) { Scope = scope; authClient = new AzureContainerRegistryClient(new TokenCredentials()) { LoginUri = $"https://{loginUrl}" }; string tempRefreshFunction() { refreshToken.CheckAndRefresh(); return(authClient.AccessTokens.GetAsync(loginUrl, scope, refreshToken.Value).GetAwaiter().GetResult().AccessTokenProperty); }; // initialize token and refresh function InitializeToken(tempRefreshFunction); }
public ContainerRegistryRefreshToken(AuthToken aadToken, string loginUrl) { // setup refresh function to retrieve acrtoken with aadtoken authClient = new AzureContainerRegistryClient(new TokenCredentials()) { LoginUri = $"https://{loginUrl}" }; string tempRefreshFunction() { // Note: should be using real new access token aadToken.CheckAndRefresh(); return(authClient.RefreshTokens.GetFromExchangeAsync("access_token", loginUrl, "", null, aadToken.Value).GetAwaiter().GetResult().RefreshTokenProperty); } // initialize token and refresh function InitializeToken(tempRefreshFunction); }