Authorization with OAuth tokens

The endpoints provided by the Authorizations API are only accessible via Basic authentication with email and password.

When creating a new authorization, the new access token for this authorization will be returned in the immediate response but not later, due to security reasons. When accessing authorizations later, you will only see the last eight chars of the token in plain text (token_last_eight) and the SHA256 digest of the token for reference (hashed_token).

For instructions on how authorization in general works, see our Auth Guide.

Scopes

When creating or updating an OAuth authorization, you can define a list of scopes to limit the access that can be performed by that authorization.

Available Scopes

Scope Description
read Read projects, locales, keys, translations, orders
write Write projects, locales, keys, translations but not orders
orders.create Create and confirm orders
team.manage Manage invitations and members

GET /v2/authorizations

List all your authorizations.

This endpoint is paginated.

Example Request

curl "https://api.phraseapp.com/api/v2/authorizations" \
  -u USERNAME
phraseapp authorizations list

Response

Status: 200
[ { "id": "abcd1234cdef1234abcd1234cdef1234", "note": "My Deploy Script", "token_last_eight": "1234abcd", "hashed_token": "abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234", "scopes": [ "read" ], "expires_at": "2015-03-30T09:52:53Z", "created_at": "2015-01-28T09:52:53Z", "updated_at": "2015-01-28T09:52:53Z" }, { "id": "abcd1234cdef1234abcd1234cdef1234", "note": "My Deploy Script", "token_last_eight": "1234abcd", "hashed_token": "abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234", "scopes": [ "read" ], "expires_at": "2015-03-30T09:52:53Z", "created_at": "2015-01-28T09:52:53Z", "updated_at": "2015-01-28T09:52:53Z" } ]

GET /v2/authorizations/:id

Get details on a single authorization.

Example Request

curl "https://api.phraseapp.com/api/v2/authorizations/:id" \
  -u USERNAME
phraseapp authorization show <id>

Response

Status: 200
{ "id": "abcd1234cdef1234abcd1234cdef1234", "note": "My Deploy Script", "token_last_eight": "1234abcd", "hashed_token": "abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234", "scopes": [ "read" ], "expires_at": "2015-03-30T09:52:53Z", "created_at": "2015-01-28T09:52:53Z", "updated_at": "2015-01-28T09:52:53Z" }

POST /v2/authorizations

Create a new authorization.

Parameters

Name Type Description
note string A note to help you remember what the access is used for.
scopes
optional
array of strings A list of scopes that the access can be used for.
expires_at
optional
datetime Expiration date for the authorization token. Null means no expiration date (default).

Example Request

curl "https://api.phraseapp.com/api/v2/authorizations" \
  -u USERNAME \
  -X POST \
  -d '{"note":"My Deploy Script","scopes":["read","write"],"expires_at":"2015-03-30T09:52:53Z"}' \
  -H 'Content-Type: application/json'
phraseapp authorization create \
--note "My Deploy Script" \
--scopes "read,write" \
--expires-at "2015-03-30T09:52:53Z"

Response

Status: 201
{ "id": "abcd1234cdef1234abcd1234cdef1234", "note": "My Deploy Script", "token_last_eight": "1234abcd", "hashed_token": "abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234", "scopes": [ "read" ], "expires_at": "2015-03-30T09:52:53Z", "created_at": "2015-01-28T09:52:53Z", "updated_at": "2015-01-28T09:52:53Z", "token": "abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234" }

PATCH /v2/authorizations/:id

Update an existing authorization.

Parameters

Name Type Description
note string A note to help you remember what the access is used for.
scopes
optional
array of strings A list of scopes that the access can be used for.
expires_at
optional
datetime Expiration date for the authorization token. Null means no expiration date (default).

Example Request

curl "https://api.phraseapp.com/api/v2/authorizations/:id" \
  -u USERNAME \
  -X PATCH \
  -d '{"note":"My Deploy Script","scopes":["read","write"],"expires_at":"2015-03-30T09:52:53Z"}' \
  -H 'Content-Type: application/json'
phraseapp authorization update <id> \
--note "My Deploy Script" \
--scopes "read,write" \
--expires-at "2015-03-30T09:52:53Z"

Response

Status: 200
{ "id": "abcd1234cdef1234abcd1234cdef1234", "note": "My Deploy Script", "token_last_eight": "1234abcd", "hashed_token": "abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234abcd1234cdef1234", "scopes": [ "read" ], "expires_at": "2015-03-30T09:52:53Z", "created_at": "2015-01-28T09:52:53Z", "updated_at": "2015-01-28T09:52:53Z" }

DELETE /v2/authorizations/:id

Delete an existing authorization. API calls using that token will stop working.

Example Request

curl "https://api.phraseapp.com/api/v2/authorizations/:id" \
  -u USERNAME \
  -X DELETE
phraseapp authorization delete <id>

Response

Status: 204