Every request to the review API carries a Proofline token in the Authorization header. A token works in one organization, with the scopes and repositories chosen when it was created.
import { ProoflineClient } from "@proofline/sdk";
// The client sends the token in the Authorization header of every request.
const client = new ProoflineClient({
baseUrl: "https://proofline.sh",
token: process.env.PROOFLINE_TOKEN!,
});
const page = await client.listReviews({
path: { org_id: process.env.PROOFLINE_ORGANIZATION_ID! },
});
console.log(page.items.length);import os
from uuid import UUID
from proofline import ProoflineClient
# The client sends the token in the Authorization header of every request.
with ProoflineClient(os.environ["PROOFLINE_TOKEN"]) as client:
page = client.list_reviews(UUID(os.environ["PROOFLINE_ORGANIZATION_ID"]))
print(len(page.items))curl -sS "https://proofline.sh/api/v1/organizations/$PROOFLINE_ORGANIZATION_ID/reviews" \
-H "Authorization: Bearer $PROOFLINE_TOKEN"Tokens#
A token acts with its holder's current GitHub identity and access. It reads or requests reviews and never changes configuration, billing, seats, cloud access, integrations or other tokens. Those actions need a signed-in browser.
| Kind | Created by | Default lifetime | Longest lifetime |
|---|---|---|---|
| Personal | You, from Personal tokens in the account menu | 30 days | 90 days |
| Organization | An administrator, from the organization's API tokens settings | 90 days | 365 days |
| CLI device | A command-line tool, through device sign-in | 14 days | 14 days |
The console shows a token's secret once, when you create it. Revoking a token takes effect on its next request.
Scopes#
Each operation needs one scope. Give a token only the scopes its job needs.
| Scope | Operations |
|---|---|
analytics:read | GET /exports/{dataset} |
reviews:read | listRepositories, listReviews, getReview, getReviewRouting, getDeploymentReview, listPullRequestReviews, getPullRequestReview |
findings:read | getAssessment, getFinding |
guidance:read | getReviewGuidance |
reviews:rerun | rerunReview |
reviews:request | requestPatchReview, requestReview |
A token can also be limited to a list of repositories. An organization token that requests or reruns reviews must name its repositories. A pull request review request and a rerun check that the holder can still write to the repository on GitHub. A review request for local changes checks that the holder can still read it, because that review is never posted to GitHub.
Errors#
Errors are RFC 9457 problem documents, and the HTTP status is authoritative.
| Status | Meaning |
|---|---|
| 400 | The request sent both a session cookie and a token. |
| 401 | The token is missing, malformed, expired or revoked. |
| 404 | The organization or object is outside what the token can see. |
| 429 | The token made more than 600 requests in a minute. Wait for Retry-After. |
A 404 also answers when the holder has left the organization, or when the administrator who created an organization token has lost that role.
Device sign-in#
A command-line tool signs in through your browser, so you never copy a token. The tool asks for a code, opens the approval page, and waits while you choose the organization, the scopes and the repositories.
- The tool sends
POST /auth/device/codewith the scopes it wants. The response has adevice_code, auser_code, averification_uriand averification_uri_complete. - The tool opens
verification_uri_completein your browser. The page shows the code, so you only check that it matches the one in your terminal. - You approve. The approval needs a signed-in browser session, and you can narrow the scopes and repositories first.
- The tool polls
POST /auth/device/tokenwith thedevice_codeandgrant_type=urn:ietf:params:oauth:grant-type:device_code. It receives anaccess_token, a CLI device token that lasts 14 days, and anorganization_idnaming the organization you approved. The token works only there, so the tool puts that ID in every API path.
The code expires after 10 minutes. Poll every 5 seconds to start with. Before approval, polling returns authorization_pending; polling too fast returns slow_down and adds five seconds to the interval. An expired or used code returns expired_token. Each code issues one token, however many times it is polled.