Skip to content

refactor: use API token instead of legacy API key#797

Closed
twsansbury wants to merge 13 commits intocloudflare:productionfrom
twsansbury:use-api-token
Closed

refactor: use API token instead of legacy API key#797
twsansbury wants to merge 13 commits intocloudflare:productionfrom
twsansbury:use-api-token

Conversation

@twsansbury
Copy link

Some products provides usage examples for the legacy API keys authorization scheme. Where possible, the documentation and usage examples should direct users to use the recommended API tokens authorization scheme.

Copy link
Contributor

@bkrebsbach bkrebsbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stream changes LGTM

@twsansbury
Copy link
Author

@bkrebsbach, the stream documentation was updated in #149 to start using API tokens. The GraphQL usage example uses an API token:

curl --request POST \
--url https://api.cloudflare.com/client/v4/graphql \
--header 'content-type: application/json' \
--header 'Authorization: Bearer $TOKEN' \
--data '{"query":"query {\n viewer {\n accounts(filter:{\n accountTag:\"$ACCOUNT_ID\"\n\n }) {\n videoPlaybackEventsAdaptiveGroups(\n filter: {\n date_geq: \"2020-09-01\"\n date_lt: \"2020-09-25\"\n }\n orderBy:[uid_ASC]\n limit: 10000\n ) {\n count\n sum {\n timeViewedMinutes\n }\n dimensions{\n uid\n }\n }\n }\n }\n}\n\n"}'

However, the document explicitly states API tokens cannot be used:

## Limitations
- Only Cloudflare API keys, not API tokens can be used with the Stream GraphQL API for now

These seem to be in conflict with one another. If I knew which was correct, I would be glad to fix the documentation as part of this pull request.

@bkrebsbach
Copy link
Contributor

@Everlag / @renandincer - do we not support API tokens? See @twsansbury's comments:

@bkrebsbach, the stream documentation was updated in #149 to start using API tokens. The GraphQL usage example uses an API token:

curl --request POST \
--url https://api.cloudflare.com/client/v4/graphql \
--header 'content-type: application/json' \
--header 'Authorization: Bearer $TOKEN' \
--data '{"query":"query {\n viewer {\n accounts(filter:{\n accountTag:\"$ACCOUNT_ID\"\n\n }) {\n videoPlaybackEventsAdaptiveGroups(\n filter: {\n date_geq: \"2020-09-01\"\n date_lt: \"2020-09-25\"\n }\n orderBy:[uid_ASC]\n limit: 10000\n ) {\n count\n sum {\n timeViewedMinutes\n }\n dimensions{\n uid\n }\n }\n }\n }\n}\n\n"}'

However, the document explicitly states API tokens cannot be used:

## Limitations
- Only Cloudflare API keys, not API tokens can be used with the Stream GraphQL API for now

These seem to be in conflict with one another. If I knew which was correct, I would be glad to fix the documentation as part of this pull request.

@bkrebsbach
Copy link
Contributor

@twsansbury The limitation requiring API keys is no longer valid, I've confirmed that API tokens work for Stream.

Copy link
Contributor

@tlozoot tlozoot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM. fyi @crwaters16 as well

@twsansbury
Copy link
Author

Given the number of code owners, should I split this into different merge requests? I am worried I will continuously need to rebase and resolve merge conflicts while waiting for approval from other code owners.

Next, you will need to add the CNAME record that is provided in the results, ie `name: _ca3-fbc2086e83a647d4822fefa68f26fc55.cname.example.com` and `cname_target:dcv.digicert.com`, at the Authoritative DNS provider for the hostname. This CNAME record information can also be located in the Custom Hostname section of the SSL dashboard.

The certificate should validate relatively soon after its added. If you’d like to check immediately simply send a `PATCH` with the same payload. No newline at end of file
The certificate should validate relatively soon after its added. If you’d like to check immediately simply send a `PATCH` with the same payload.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "it is" or "it's"

@KimJ15 KimJ15 added the product:analytics Related to Analytics product label Apr 8, 2021
@gitguardian
Copy link

gitguardian bot commented Jul 16, 2022

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
- Generic High Entropy Secret 7d3d958 config.toml View secret
- Generic High Entropy Secret 58b6333 products/ddos-protection/docs-config.js View secret
- Generic High Entropy Secret f5ad72d products/ddos-protection/docs-config.js View secret
3543783 Generic High Entropy Secret 51cbbad products/ruleset-engine/docs-config.js View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@KimJ15
Copy link
Collaborator

KimJ15 commented Jul 20, 2022

This PR was opened before the developer doc site was moved to Cloudflare Pages. There are many conflicting branches. I'm going to close it now, but feel free to open a new issue or ask any questions.

@KimJ15 KimJ15 closed this Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:analytics Related to Analytics product

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants