8000 Added a use case of secure API token in YML by darssy · Pull Request #873 · appveyor/website · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added a use case of secure API token in YML #873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ $headers["Content-type"] = "application/json"
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/roles' -Headers $headers -Method Get
```

### YML
Your API token needs to be stored in a [secure variable](/docs/build-configuration/#secure-variables) before appearing in a `yml` file. You can store it in an environment variable for that purpose. As a result the above PowerShell snippet will be written in a yml file as follows:

```yml
environment:
api_token:
secure: <your-secure-api-token>
before_build: #just an example
- ps: |
$token = $env:api_token
$headers = @{}
$headers['Authorization'] = "Bearer $token"
$headers["Content-type"] = "application/json"
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/roles' -Headers $headers -Method Get
```

<!-- markdownlint-disable MD003 MD022 -->
### C\#
<!-- markdownlint-enable MD003 MD022 -->
Expand Down
0