Authentication

Introduction

User authentication is done using the OAuth protocol. You must authorize users through this protocol in order for your application to have access to its data. Below you can see all the available methods. You can read more about user authorization read here.

Method call

To invoke methods, an OAuth object is used. All methods are located within this URL:

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

Available OAuth Object Methods

Method Usage For
OAuth.get_link Get authentication link API/SDK
OAuth.login Authorization in the system / Confirmation of access rights Frontend
OAuth.app_info Getting information about the application Frontend
OAuth.approve_application Confirm application API/SDK
OAuth.complete The page displayed on the successful verification of rights Frontend
OAuth.get_token Receive authorization token API/SDK
OAuth.logout Reset application token and authorization API/SDK

OAuth.get_link

This method is designed to get an authorization link. After receiving the link for authorization, you must redirect the user there to confirm authorization in your application. You can read more about user authorization read here.

Method URL

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

Submitted Data

Name Type Usage
app_id double Ocugine Project ID
app_key string Ocugine Project Client Key
grants (Not necessary) string/array 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.

Received data

Name Type Usage
complete bool Operation Status
message string Error message If complete = false, returns null.
auth_url string URL to authorize the user in the application
timeout double Unix link activity expiration time

OAuth.login

This method is used to directly authorize the user and issue rights. This method is used only in the browser (frontend) and does not require API actions.

Method URL

https://cp.ocugine.pro/oauth/login/

Submitted Data (GET)

Name Type Usage
key string Ocugine API Authentication Key

Method Description

If the user is not authorized - he will be redirected to the login page:

https://cp.ocugine.pro/auth/

In this case, the authorization page will be passed a parameter about the redirect. After successful login, the user will be redirected back to the OAuth.login page.

After the user has been redirected back, or he was initially authorized in the system, he will be asked to allow the application to access his data. With the request to the API from this form, a request for permission will be sent. You do not need to perform any operations on your part.

If the permission is successful, the user will be redirected to the OAuth.complete page.

OAuth.app_info

This page opens only in the browser. On this page, the user can view the main information about the application - its name, description and image. You do not need to redirect the user there. He himself can go to this page from the page issuing access rights during authorization.

Method URL

https://cp.ocugine.pro/oauth/app_info/

OAuth.approve_application

This API is used to confirm authorization in the application. This method is not described, as it is used only within authorizations performed in the browser without the need for your application to participate.

Method URL

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

OAuth.complete

The user will be redirected to this page in case of successful authorization and confirmation of the rights of your application. You have to catch the closure of the page when the user is on it, to then request the user's token.

Method URL

https://cp.ocugine.pro/oauth/complete/

OAuth.get_token

This method is designed to obtain an access token. This token is used later to access user data. After receiving the token, you can work with user queries and data. You can read more about user authorization read here.

Method URL

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

Submitted Data

Name Type Usage
app_id double ID вашего проекта на Ocugine
app_key string Client Key вашего проекта на Ocugine
lang (Not nessesary) string The language in which the server response comes. The default is determined automatically.

Received Data

Name Type Usage
complete bool Operation Status
message string Error message If complete = false, returns null.
access_token string User authorization token. Used to work with custom methods and data.

OAuth.logout

This method is designed to reset the access token (cancel the issuance of rights and authorization). After executing this method, you will not be able to access user data and methods using this token. You can read more about user authorization read here.

Method URL

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

Submitted Data

Name Type Usage
access_token string Access Token for reset

Received Data

Name Type Usage
complete bool Operation Status
message string Error message If complete = false, returns null.