API

Common

Getting Started

User

Register New User
Login
Logout
Refresh Access Token
Get User Profile
Update Profile
Upload Avatar
Delete User
Reset Password
Reset Password by ID

User Token

List User Tokens
Add User Token
Update Default User Token
Delete User Token
Verify User Token
Reset Verification Code

User vAtom

Get vAtom
Get vAtoms by Ids
Get vAtom Inventory
Search vAtoms
Geo Discover Groups
Geo Discover vAtoms
Update vAtoms
Perform Action
Trash vAtom

User Activity

Get My Threads
Get My Thread Messages

Template

List Templates
Get Template
Create Template
Update Template
Delete Template

Template Variation

List Variations
Get Variation
Create Variation
Update Variation
Delete Variation

vAtom

Emit vAtom

Template Action

List Actions
Get Action
Register Action Handler
Register Action
Update Action
Delete Action

Template Face

List Faces
Register Face
Update Face
Delete Face

Asset

Upload Assets
Get Assets
Delete Assets

Login

POST
https://api.blockv.io/v1/user/login

Overview

A user can have multiple unique "tokens" which are used to identify the user. Examples of such tokens include an e-mail address, phone number, or an OAuth provider. A user can login with any of the tokens. At least one token is mandatory for authentication, besides in one notable case...

It is also possible to login via a guest_id. If a vAtom is sent to a user that is not recognized by our API, a "guest user" is created for them along with a guest_id token that is typically sent to them via email or SMS. The user can then login with their guest_id and set a password via the Update Profile endpoint to remove the guest authentication.

Login Request

HTTP Headers

Content-Type: application/json App-Id: {app_id}

Payload Details

NameTypeDescription
tokenstringThe value of the token, for example john.doe@example.com
token_type * stringThe type of the token, for example email .
auth_dataobjectContains the data that is used for authentication.

Auth data

The data that is required for authentication depends on the type of token used for authentication.

phone and email tokens must be authenticated via a password string.

oauth token types are authenticated via an oauth_token string that is verified with a third party provider.

Sample Request: Login via email

{
	"token" : "john.doe@example.com",
	"token_type" : "email",
	"auth_data" : {
		"password": "secret"
	}
}

Sample Request: Login via telephone number

{
	"token" : "+11234567890",
	"token_type" : "phone_number",
	"auth_data" : {
		"password": "secret"
	}
}

Sample Request: Login via guest ID

{
	"token" : "afd437ec-83c5-4b7f-b3fd-ceead09101bc",
	"token_type" : "guest_id"
}

When logging in via Facebook, the token is omitted in the request since it will be returned by the Facebook OAuth flow. Instead the oauth_token received from Facebook as part of the oAuth flow is submitted. The oauth_token will then be used to call the Facebook API and find the matching ID returned by Facebook.

Sample Request: Login via Facebook

{
	"token_type" : "facebook",
	"auth_data" : {
		"oauth_token": "CAAKufIJSLC0BAEyrQkyFsCb2ziiwa...."	
	}
}

Login Response

On successful authentication two JWTs (RFC 7519) will be returned as part of the HTTP response body:

  1. access_token - This token MUST be passed as Bearer (scheme) token in the HTTP Authorization header. It is not an OAuth token even though the naming convention matches OAuth's. This token will be valid for 5 minutes after the login request is made.
  2. refresh_token - This token is for used to Refresh the Access Token.

Return & Error Codes

ErrorTypeDescription
200httpEverything is OK
400httpBad Request
403httpNot Authorized

payload Object

NameTypeDescription
userobjectThe user object that was created.
[ asset_provider ]arrayAn array of asset_provider objects.
access_tokenstringA JWT access token according to RFC 7519, which will be valid for 5 minutes.
refresh_tokenstringA refresh token used to request a new access token.

Sample Response

{
    "payload": {
        "user": {
            "id": "001d0933-88e6-4e17-b147-0f672dc016d1",
            "meta": {
                "data_type": "blockv::user",
                "when_created": "2018-01-01T00:00:00+00:00",
                "when_modified": "2018-01-01T00:00:00+00:00"
            },
            "properties": {
                "first_name": "John",
                "last_name": "Doe",
                "name_public": false,
                "avatar_uri": "http://example.com/mypic.jpg",
                "avatar_public": false,
                "birthday": "1970-01-01",
                "nonpush_notification": false,
                "language": "en"
            },
            "system_properties": {
                "pub_fqdn": "publisher_fqdn",
                "is_admin": false,
                "activated": false,
                "last_login": "",
                "is_merchant": false,
            }
        },
        "asset_provider": [
            {
                "name": "blockv",
                "type": "Cloudfront",
                "descriptor": {
                    "CloudFrontPolicy": "eyJTdGF0ZW1lbnQi...",
                    "CloudFronSignature": "HEroZOBNqC4ld...",
                    "CloudFrontKeyPairId": "APKAIB7W534.."
                }
            }
        ],
        "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6...",
        "refresh_token": "APHpa3JD9XwQ2DqISfq8YtnVPQUn..."
    }
}

access_token JWT as JSON

{
  "user_id": "29828993-c2b4-4f6b-a289-f4bdd965d068",
  "pub_fqdn": "publisher_fqdn",
  "is_admin": true,
  "activated": false,
  "exp": 1518020257,
  "jti": "ab2c2eb2-b2a3-4f56-a19b-0af82020f755",
  "iss": "ebd04065-41d3-4e30-9844-24c594f6b17f",
  "sub": "access"
}
©2020 BLOCKv
Info