User API \ Import a user by using an external token PHP SDK

Resource/URI GET POST PUT DELETE
Users /users.json List all users Import access token
User /users/<user_token>.json Retrieve user details Delete user
User /users/<user_token>/contacts.json Read contacts
User /users/<user_token>/publish.json Publish on social networks

Workflow

Request: the code to send to the API

Send an API request to the following endpoint in order to create a new or update an existing user record based on the data provided by an access or JSON web token received from a social network.

PUT /users.json

This endpoint can be used to migrate existing user records to OneAll or to import users that login with the native SDK of a social network on a mobile device. The endpoint requires no authentication so that it can be implemented in mobile applications without having to store the public/private keys of your OneAll site on the device.

Import using an access_token

The OneAll API will use the access token to retrieve the user's data from the given social network and then either create a new user record or update the existing record in your OneAll site.

Import using a JWT/id_token

The OneAll API will decrypt and validate the JWT and then either create a new user record or update the existing record in your OneAll site.

PUT data to include in the request

	{
		"request": {
			"user": {
				"user_token": "#user_token#",
				"identity": {
					"source": {
						"key": "#provider_key#",
						"access_token": {
							"key": "#access_token_key#",
							"secret": "#access_token_secret#"
						},
            "id_token": {
              "value": "#id_token_value#"
            }
					}
				}
			}
		}
	}
Key Description
#user_token# An optional user_token to link the imported social network profile to.
Example: 24f6eaef-7537-45b3-bf4c-0c2a772bdee4
* #provider_key# The key of the social network from which the token originates.
Example: facebook
Import using an access_token
* #access_token_key# The user's access token as received from the social network.
Example: CAABwiWr8tH8BAGKCYOIgoMwJ9T0ZAmJ6KJJNcUjzmftdAOC [...]
#access_token_secret# The user's access token secret as received from the social network.
Example: T0OzJdwrUy3arA8kqZTTkYDkLPI3WRppmJ6KJJNcUjzmftdAOC [...]
Import using a JWT/id_token
* #id_token_value# The user's JWT/id_token as received from the social network.
Example: eyJhbGciOiJIUzI1NiIsInR5cCI6ICJ9.eyJ...KxwRJSM2QT4fwpMeJf36POk6yJV_adQssw5c

Result: the code returned by the API

If the given token is valid, the API will return the details of the created/updated user record. The identity node represents the imported social network profile data. Depending on the social network, more or less information is available.

The API may return one of the following HTTP status codes:

  • 201: There was no user for the given token and a new user record has been created.
  • 200: There was already a user for the given token and the exisiting user record has been updated.
  • ???: In any other case an error has occured

Example for a record created using a Google access token:

{
  "response": {
    "request": {
      "date": "Wed, 05 Dec 2018 09:48:36  0100",
      "resource": "/users.json",
      "status": {
        "flag": "success",
        "code": 200,
        "info": "Your request has been processed successfully"
      }
    },
    "result": {
      "data": {
        "user": {
          "user_token": "6dcd7aac-bb99-442b-ad53-9c28bd3f349a",
          "identity": {
            "identity_token": "13798415-7d5b-4b80-902e-4289278b8046",
            "date_creation": "Fri, 08 Feb 2013 22:07:46  0100",
            "date_last_update": "Wed, 05 Dec 2018 09:48:36  0100",
            "provider": "google",
            "provider_identity_uid": "PIU24E1073E581F3D57C7BAFD7A4DB55085",
            "source": {
              "name": "Google",
              "key": "google",
              "access_token": {
                "key": "xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx",
                "date_expiration": "05/04/2015 14:06:08"
              },
              "refresh_token": {
                "key": "yyyy.yyyy.yyyy.yyyy.yyyy.yyyy.yyyy"
              }
            },
            "id": "https://plus.google.com/123456789012345678901",
            "displayName": "John Doe",
            "name":{
              "formatted": "John Doe",
              "givenName": "John",
              "familyName": "Doe"
            },
            "preferredUsername": "John Doe",
            "profileUrl": "https://plus.google.com/123456789012345678901",
            "pictureUrl": "https://lh3.googleusercontent.com/-abcdefghijkl/AAAAAAAAAAI/AAAAAAAAAFY/12345678901/photo.jpg?sz=300",
            "gender": "male",
            "emails": [
              {
                "value": "john.doe@example.com",
                "is_verified": true
              }
            ],
            "urls": [
              {
                "value": "https://plus.google.com/123456789012345678901",
                "type": "profile"
              }
            ],
            "accounts": [
              {
                "domain": "google.com",
                "userid": "123456789012345678901"
              }
            ],
            "photos": [
              {
                "value": "https://lh3.googleusercontent.com/-abcdefghijkl/AAAAAAAAAAI/AAAAAAAAAFY/12345678901/photo.jpg?sz=50",
                "size": "3:S"
              },
              {
                "value": "https://lh3.googleusercontent.com/-abcdefghijkl/AAAAAAAAAAI/AAAAAAAAAFY/12345678901/photo.jpg?sz=150",
                "size": "4:M"
              },
              {
                "value": "https://lh3.googleusercontent.com/-abcdefghijkl/AAAAAAAAAAI/AAAAAAAAAFY/12345678901/photo.jpg?sz=300",
                "size": "5:L"
              }
            ],
            "languages": [
              {
                "value": "English"
              }
            ],
            "locales": [
              {
                "value": "en",
                "description": "English"
              }
            ],
            "relationship": {
              "status": "Married"
            }
          },
          "identities": [
            {
              "identity_token": "13798415-7d5b-4b80-902e-4289278b8046",
              "provider": "google"
            },
            {
              "identity_token": "8d78418f-20c2-47de-af29-27514de6c7ce",
              "provider": "facebook"
            }
          ]
        }
      }
    }
  }
}

User Contributed Notes