tag:help.appveyor.com,2012-11-13:/discussions/questions/58347-is-it-possible-to-use-authorization-bearer-token-encruptedAppVeyor: Discussion 2022-05-28T12:40:44Ztag:help.appveyor.com,2012-11-13:Comment/544630922022-05-28T10:43:01Z2022-05-28T12:40:44ZIs it possible to use Authorization: Bearer token encrupted?<div><p>Well never mind. I figured this out (with some hints from this discussion forum 😊)</p>
<p>It's as simple as doing<br></p>
<pre>
<code>environment:
my_api_token:
secure: [the encrypted value here]</code>
</pre>
<p>And the key is that <strong>you can use the my_api_token in the script without any gimmicks</strong>:</p>
<pre>
<code> $apiUrl = 'https://ci.appveyor.com/api'
$accountName = $env:APPVEYOR_ACCOUNT_NAME
$projectSlug = $env:APPVEYOR_PROJECT_SLUG
$token = $env:my_api_token
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
"Accept" = "application/json"
}
$build = @{
nextBuildNumber = 0
}
$json = $build | ConvertTo-Json
Invoke-RestMethod -Method Put $apiUrl/projects/$accountName/$projectSlug/settings/build-number -Body $json -Headers $headers</code>
</pre>
<p>If that's ok with you (when my time permits it) I will create a pull request in the documentation to mention that small detail -maybe that will save the next poor soul some time. :)</p></div>adamstyl