How to authenticate without sending my username and password for HTTP requests?

Currently, following is how I am sending request from PS to update a parameter:

$pair="$("username"):$("password")"
$encodedCreds=[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue="Basic $encodedCreds"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", $basicAuthValue)
$headers.Add("Content-Type", 'text/plain')
$headers.Add("Origin", 'https://teamcity.server.io')
Invoke-RestMethod -Method Put -Uri $url -Headers $headers -Body $updated_version
 
But I do not want my username and password mentioned like this anymore.
What other ways do I have to authenticate myself for HTTP requests?
 
 
0
1 comment

Hi Ibrahim,

This lists the current supported authentication methods for the REST API: https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-RESTAuthentication

The best way to go around this is to have specific users that have the exact permissions to only perform the tasks that should be performed via REST.

We already have a request to authenticate via some token, if you would be interested there please watch and vote here: https://youtrack.jetbrains.com/issue/TW-3161

A possible workaround as of now would be the following, but it has some limitations:
https://youtrack.jetbrains.com/issue/TW-14209#comment=27-485445

Hope this helps.

0

Please sign in to leave a comment.