Session

Login

POST
https://peertube2.cpy.re/api/v1/users/token

With your client id and secret, you can retrieve an access and refresh tokens.

Body

application/x-www-form-urlencoded
One of
client_idstringrequired
Example
v1ikx5hnfop4mdpnci8nsqh93c45rldf
client_secretstringrequired
Example
AjWiOapPltI6EnsWQwlFarRtLh4u8tDt
grant_typestringpasswordrequired
usernameusernamerequired

immutable name of the user, used to find or mention its actor

Example
chocobozzz
externalAuthTokenstring

If you want to authenticate using an external authentication token you got from an auth plugin (like peertube-plugin-auth-openid-connect for example) instead of a password or a refresh token, provide it here.

client_idstringrequired
Example
v1ikx5hnfop4mdpnci8nsqh93c45rldf
client_secretstringrequired
Example
AjWiOapPltI6EnsWQwlFarRtLh4u8tDt
grant_typestringrefresh_tokenrequired
refresh_tokenstringrequired
Example
2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7

Parameters

x-peertube-otpstringheader

If the user enabled two factor authentication, you need to provide the OTP code in this header

Response

200OKobject

successful operation

Response fields application/json
token_typestring
Example
Bearer
access_tokenstring

valid for 1 day

Example
90286a0bdf0f7315d9d3fe8dabf9e1d2be9c97d0
refresh_tokenstring

valid for 2 weeks

Example
2e0d675df9fc96d2e4ec8a3ebbbf45eca9137bb7
expires_ininteger>= 0
Example
14399
refresh_token_expires_ininteger>= 0
Example
1209600
400Bad Request

Disambiguate via code:

  • invalid_client for an unmatched client_id
  • invalid_grant for unmatched credentials
401Unauthorized

Disambiguate via code:

  • default value for a regular authentication failure
  • invalid_token for an expired token
  • missing_two_factor if two factor header is missing