mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
Greenfield API clarifications, fix typo subscriptions -> registrations (#5955)
This commit is contained in:
parent
8d429f064b
commit
c23fab5b34
@ -92,7 +92,7 @@
|
||||
"Users"
|
||||
],
|
||||
"summary": "Create user",
|
||||
"description": "Create a new user.\n\nThis operation can be called without authentication in any of this cases:\n* There is not any administrator yet on the server,\n* The subscriptions are not disabled in the server's policies.\n\nIf the first administrator is created by this call, subscriptions are automatically disabled.",
|
||||
"description": "Create a new user.\n\nThis operation can be called without authentication in any of this cases:\n* There is not any administrator yet on the server,\n* User registrations are not disabled in the server's policies.\n\nIf the first administrator is created by this call, user registrations are automatically disabled.",
|
||||
"requestBody": {
|
||||
"x-name": "request",
|
||||
"content": {
|
||||
@ -149,7 +149,7 @@
|
||||
"description": "If you need to authenticate for this endpoint (ie. the server settings policies lock subscriptions and that an admin already exists)"
|
||||
},
|
||||
"403": {
|
||||
"description": "If you are authenticated but forbidden to create a new user (ie. you don't have the `unrestricted` permission on a server administrator or if you are not administrator and registrations are disabled in the server's policies)"
|
||||
"description": "If you are authenticated but forbidden to create a new user (ie. you don't have the `unrestricted` permission on a server administrator or if you are not administrator and user registrations are disabled in the server's policies)"
|
||||
},
|
||||
"429": {
|
||||
"description": "DDoS protection if you are creating more than 2 accounts every minutes (non-admin only)"
|
||||
|
@ -1,15 +1,24 @@
|
||||
|
||||
# GreenField API Authorization Flow
|
||||
|
||||
The GreenField API allows two modes of authentication to its endpoints: Basic auth and API Keys.
|
||||
The GreenField API allows two modes of authentication to its endpoints: Basic Auth and API keys.
|
||||
|
||||
## Basic auth
|
||||
Basic auth allows you to seamlessly integrate with BTCPay Server's user system using only a traditional user/password login form. This is however a security risk if the application is a third party as they will receive your credentials in plain text and will be able to access your full account.
|
||||
|
||||
## API Keys
|
||||
BTCPay Server's GreenField API also allows users to generate API keys with [specific permissions](https://docs.btcpayserver.org/API/Greenfield/v1/#section/Authentication/API%20Key). **If you are integrating BTCPay Server into your third-party application, this is the recommended way.**
|
||||
BTCPay Server's Greenfield API also allows users to generate API keys with [specific permissions](https://docs.btcpayserver.org/API/Greenfield/v1/#section/Authentication/API_Key). **If you are integrating BTCPay Server into your third-party application, this is the recommended way.**
|
||||
|
||||
Asking a user to generate a dedicated API key, with a specific set of permissions can be a bad UX experience. For this scenario, we have the [Authorize User UI](https://docs.btcpayserver.org/API/Greenfield/v1/#tag/Authorization). This allows external applications to request the user to generate an API key with a specific set of permissions by simply generating a URL to BTCPay Server and redirecting the user to it.
|
||||
### Manually create an API key
|
||||
Users can create a new API key in the BTCPay Server UI under `Account` -> `Manage account` -> `API keys`
|
||||
|
||||
### Create API keys over the API itself
|
||||
|
||||
A user can create an API key for themselves using the [Create API Key endpoint](https://docs.btcpayserver.org/API/Greenfield/v1/#operation/APIKeys_CreateAPIKey) via Basic Auth or an unrestricted API key. Server administrators can create API keys for any user using the [Create API key for user endpoint](https://docs.btcpayserver.org/API/Greenfield/v1/#operation/ApiKeys_CreateUserApiKey).
|
||||
|
||||
### Interactive API key setup flow
|
||||
|
||||
Asking a user to generate a dedicated API key, with a specific set of permissions manually can be a bad UX experience. For this scenario, we have the [Authorize User UI](https://docs.btcpayserver.org/API/Greenfield/v1/#tag/Authorization). This allows external applications to request the user to generate an API key with a specific set of permissions by simply generating a URL to BTCPay Server and redirecting the user to it.
|
||||
Additionally, there are 2 optional parameters to the endpoint which allow a more seamless integration:
|
||||
* if `redirect` is specified, once the API key is created, BTCPay Server redirects the user via a POST submission to the specified `redirect` URL, with a json body containing the API key, user id, and permissions granted.
|
||||
* if `applicationIdentifier` is specified (along with `redirect`), BTCPay Server will check if there is an existing API key associated with the user that also has this application identifier, redirect host AND the permissions required match. `applicationIdentifier` is ignored if `redirect` is not specified.
|
||||
|
Loading…
Reference in New Issue
Block a user