Skip to content
Bare BitcoinDevelopers

Search documentation

↑ ↓ Select · Enter Open · Escape Close

barebitcoin.no ↗
Menu
View Markdown

OAuth

OAuth provides access to supported operations on behalf of another user. Contact Bare Bitcoin to arrange client registration and your redirect URI. Registration is not self-service in these docs.

Authorization code flow

The authorization server is https://barebitcoin.no, where the user signs in. API requests go to https://api.bb.no.

Direct the user to https://barebitcoin.no/oauth2/authorize with response_type=code, your registered client_id, redirect_uri, requested scope, and an unpredictable state value. Validate the returned state before exchanging the authorization code. Use PKCE with an S256 challenge for public clients; keep the verifier for the token exchange.

Exchange the code by POSTing form-encoded parameters to https://barebitcoin.no/oauth2/token: grant_type=authorization_code, code, client_id, redirect_uri, and the PKCE code_verifier when used. Confidential clients also send their registered client_secret in the form body. Never put a client secret in browser code.

Access and refresh tokens

Send the access token in the Authorization: Bearer header. Use the token response's expiry information; do not assume an access token remains valid indefinitely. Refresh using a form-encoded POST to the token endpoint with grant_type=refresh_token, refresh_token, and your client authentication. Persist replacement tokens returned by the server.

Scopes

Request only the scopes your integration needs. Each client is registered with the scopes it may request, and the authorization server rejects a request for any other scope with invalid_scope.

ScopeGrantsEndpoints
api:accounts:bitcoin:readSee balance and names of your bitcoin accountsList bitcoin accounts, Tax balances
api:trades:readSee executed tradesList trades
api:tax:transactions:readRead transactions relevant for tax calculationTax transactions
api:deposits:lightning:readSee Lightning invoices and their payment statusGet Lightning invoice
api:deposits:lightning:writeCreate Lightning invoices for payments to youCreate Lightning invoice

Server metadata

The authorization server publishes its metadata (RFC 8414) at https://barebitcoin.no/.well-known/oauth-authorization-server.

Model Context Protocol

The MCP server accepts an access token from this flow.

An application disconnects itself with revoke consent, using one of its own access tokens. This removes its access and invalidates its tokens. An application cannot revoke another application's consent, and API keys cannot revoke consent.