Tokens represent a valid user for a specific period of time for the purposes of authentication.
Name | Property Name | Data Type | Optional | Description |
---|---|---|---|---|
Token | token |
String | No | A JSON Web Token [1] |
[1] The token
property consists of a JSON Web Token which has a standardised structure described here.
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9ic2x3ZWItZGVuaXplbnMtZGV2LXdlYjFcL2FwaVwvdjFcL3Rva2VucyIsInN1YiI6MSwiaWF0IjoxNDIxMTQ3MTUzLCJleHAiOjE0MjExNTA3NTN9.LIlwJ9IXwMxjh8dxkIw9XbvwWz1juFq8f7pE0dC7Gbc"
}
[POST]/tokens
[DELETE]/tokens
[POST]/tokens
Issues a new token to a valid user.
Trait | Enabled |
---|---|
Authenticated | No |
Hard limit | No |
None.
Name | Field Name | Data Type | Valid Value(s) | Description |
---|---|---|---|---|
Username | username |
String | A valid user’s username | - |
Password | password |
String | A valid user’s password | - |
URL: https://api.bas.ac.uk/people/v1/tokens
Key | Value |
---|---|
Content-Type | application/json |
Accept | application/json |
{
"username": "conwat",
"password": "password"
}
Note: Interactive examples for this method may be covered in the examples document.
Key | Value |
---|---|
Content-Type | application/json |
{
"notices": [
{
"type": "token_generated",
"details": {
"expiry": {
"expires": 1421150753,
"message": "This token will expire at: 2015-01-13 12:05:53, at which point you will need to request a new token."
}
}
}
],
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9ic2x3ZWItZGVuaXplbnMtZGV2LXdlYjFcL2FwaVwvdjFcL3Rva2VucyIsInN1YiI6MSwiaWF0IjoxNDIxMTQ3MTUzLCJleHAiOjE0MjExNTA3NTN9.LIlwJ9IXwMxjh8dxkIw9XbvwWz1juFq8f7pE0dC7Gbc"
}
}
[DELETE]/tokens
Manually invalidate a currently valid token before it invalidates naturally.
Trait | Enabled |
---|---|
Authenticated | Yes |
Hard limit | No |
None.
None.
“Natural” invalidation refers to how tokens will automatically be considered invalid when they reach their expiration date.
See the authentication document for further information on this concept.
URL: https://api.bas.ac.uk/people/v1/tokens
(example)
Key | Value |
---|---|
Content-Type | application/json |
None.
Note: Interactive examples for this method may be covered in the examples document.
Key | Value |
---|---|
Content-Type | application/json |
{
"notices": [
{
"type": "token_blacklisted",
"details": {
"token_blacklist": {
"message": "This token is now blacklisted and will be refused if used again."
}
}
}
]
}
unknown_blacklist_fault
)Key | Value |
---|---|
Content-Type | application/json |
{
"errors": [
{
"resolution": "Try again, or wait for the token to expire naturally. If needed, contact the API maintainer for assistance.",
"resolutionURLs": [
"mailto:basweb@bas.ac.uk"
],
"type": "unknown_blacklist_fault"
}
]
}
Note: The format of this error will change in future API versions (to standardise against the json:api spec.
expired_authentication_token
)Key | Value |
---|---|
Content-Type | application/json |
{
"errors": [
{
"details": {
"token_error": [
"The authentication token given has expired and is no longer valid."
]
},
"resolution": "Get a new token by re-authenticating.",
"resolutionURLs": [
"mailto:basweb@bas.ac.uk"
],
"type": "expired_authentication_token"
}
]
}
Note: The format of this error will change in future API versions (to standardise against the json:api spec.
This information may be out of date whilst this website is being redeveloped. Until then, if you have any problems using an API documented here, please contact the relevant project maintainer.