/// <summary> /// <see cref="ITableauApiService.SignInAsync"/> /// </summary> public async Task SignInAsync() { if (!String.IsNullOrWhiteSpace(Token)) { await SignOutAsync().ConfigureAwait(false); } _logger?.Information( $"Signing in to {_settingsMonitor.CurrentValue.BaseUrl} as {_settingsMonitor.CurrentValue.Username}" ); TableauCredentialRequest apiCredentialRequest = new TableauCredentialRequest( _settingsMonitor.CurrentValue.SiteContentUrl, _settingsMonitor.CurrentValue.Username, _settingsMonitor.CurrentValue.Password ); var responseString = await SendPostAsync( $"{AuthUrl}/signin", apiCredentialRequest.ToString() ).ConfigureAwait(false); ApiCredentialResponse = JsonConvert.DeserializeObject <TableauCredentialResponse>(responseString); ClearClientDefaultRequestHeaders(); _httpClient.DefaultRequestHeaders.Add("X-Tableau-Auth", Token); _httpClient.DefaultRequestHeaders.Add("Cookie", $"workgroup_session_id={Token}"); _httpClient.DefaultRequestHeaders.Add("Connection", "keep-alive"); }
/// <summary> /// <see cref="ITableauApiService.SignOutAsync"/> /// </summary> public async Task SignOutAsync() { _logger?.Debug("Signing out"); var responseString = await SendPostAsync($"{AuthUrl}/signout").ConfigureAwait(false); ApiCredentialResponse = null; ClearClientDefaultRequestHeaders(); }