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

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

Workflow

Request: the code to send to the API

Send a PUT request with the data below to the endpoint /users.json to create/update a user based on an access token received from a social network.

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

This endpoint can per example be used to migrate existing user records to OneAll or to add users that login with the native SDK of a social network on a mobile device.

The endpoint can be used without authentication so that you can use it in mobile applications without having to store the public/private keys of your OneAll site on the device.

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#"
						}
					}
				}
			}
		}
	}
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 access token originates.
Example: facebook
* #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 (Provided by only a few social networks).
Example: T0OzJdwrUy3arA8kqZTTkYDkLPI3WRppmJ6KJJNcUjzmftdAOC [...]

Result: the code returned by the API

If the given access 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 this access token, a new user has been created.
  • 200: There was already a user for this acces token, the exisiting user 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