Users

Introduction

This section describes how you can use Ocugine to authorize users in your applications and games. Some of our APIs by default require user authorization (for example, a user entry in the leaderboard).

The authorization method in the Ocugine Control Panel and your final application is different. When working with the application, you should get a token to access user data. To do this, follow the instructions below.

Authorization in the Ocugine services is as follows:

  • You send a request for a link to authorize the user and redirect him there.
  • The user is authorized in his account Ocugine in a convenient way for him in the browser.
  • After the user returns to your application, you create a request to check the user's permissions.

User Authentication

Before you start working with a user zone, you must authorize your clients. Authorization is done by redirecting your client to our gateway, or open it in the browser’s built-in application (you can also use the SDK so that you do not need to deploy your browsers or redirect users to the system).

Get Authentication Link

In order to get a link to authorize a user, you must send a POST request to:

https://cp.ocugine.pro/api/oauth/get_link/

The request parameters should include:

Params Type Usage
app_id double ID of your Ocugine Project
app_key string Client Key of your Ocugine Project
grants (Not necessary) array / string Array of parameters for access request, or "all" for requesting all rights
lang (Not necessary) string The language in which the server response comes. The default is determined automatically.

An example of the data you send:

{
    "app_id": 1,
    "app_key": "example_key",
    "grants": ["profile", "achivements", "cloud_data"],
    "lang": "EN"
}

After that, the server will give you a response of the following form, in case of successful authorization:

{
    "complete": true,
    "auth_url": "https://cp.ocugine.pro/oauth/login/?key=AUTH_KEY"
}

Where:

Params Type Usage
complete bool Authentication State
auth_url string URL to authorize the user in the application
timeout double Unix link activity expiration time

Continuing authorization

After the user has logged in and has given all permissions for your application, you must receive an access token in order to send requests to personalized API methods. To do this, after the user has returned to your application from the login window, you need to get an access token using a POST request.

To obtain a token, send a POST request to the following URL:

https://cp.ocugine.pro/api/oauth/get_token/

Where in the parameters should be specified:

Params Type Usage
app_id double ID of your Ocugine Project
app_key string Client Key of your Ocugine Project
lang (Not necessary) string The language in which the server response comes. The default is determined automatically.

For Example:

{
    "app_id": 1,
    "app_key": "example_key",
    "lang": "EN"
}

After that, you will receive the following response from the server:

{
    "complete": true,
    "access_token": "example_token",
    "grants": "all"
}

Where:

Params Type Usage
complete bool Operation Status
access_token string Token access to authorized functions Ocugine API
grants array / string Array of parameters for access request, or "all" for requesting all rights

Authorization by other methods

Your users can not log in using Ocugine login and password. For this they can use social networks. You do not need to make any additional settings for this. Authorization by alternative methods is already configured by default.

If a user has not previously been registered or has not linked a social network account to his profile, during authorization via social networks, a new Ocugine account will be automatically created for him.

Request Permissions

When performing an authorization request, you need to send a parameter with access rights. You can get various flags in the list below.

Available Permissions:

Permission Usage Defaults
profile Access to profile information Requested
reports Access to user reports Requested
payments Access to user billing information Requested
promos Access to personal promotions user Requested
support_tickets Access to user tickets in support Not Requested
reviews Access to user reviews within the application Not Requested
apps Access to the list of user-installed applications Not Requested
leaderboards Access to user points on the leaderboard Not Requested
messages Access to user messages Not Requested
achivements Access to user achievements Not Requested
teams Access to user commands Not Requested
multiplayer Access to user information in multiplayer Not Requested
social Access to social user functions Not Requested
cloud_data Access to user cloud data Not Requested

If you want to request access to all data at once, use the "all" flag in the "string" format, instead of the "string" array of flags.

Registration with Ocugine

If the user has not previously been registered with the Ocugine services, he will be asked to create his account. End users of your product will be able to use their Ocugine account for other games using our services.