Changes

Jump to: navigation, search

OAuth2/en

1,310 bytes removed, 12:17, 23 September 2014
Общая схема работы
To get ability to use Ace Stream OAuth2, you have to register as a reseller in Ace Stream system. Resellers are able to create markets - usually, these are sites through which options are sold to users. Each market gets access to OAuth2.
==Общая схема работыCommon work scheme==Реселлер размещает на своем сайте ссылку с названием вида Reseller publishes on his site a link with a name like "Войти через Log in via Ace Stream", которая ведет сюдаwhich leads here:
<nowiki>https://accounts.acestream.net/oauth/v2/auth?client_id=[CLIENT_ID]&response_type=code&redirect_uri=[REDIRECT_URI]&scope=userkey+email</nowiki>
В ссылку подставляются следующие параметрыThe following parameters are inserted in the link:* '''[CLIENT_ID]''' - идентификатор маркетаmarket's identifier, который реселлер может узнать в настройках своего маркетаwhich the reseller can find out in settings of his market* '''[REDIRECT_URI]''' - ссылкаlink, на который будет перенаправлен пользователь после успешной авторизацииto which the user will be redirected after a successful login. Данная ссылка должна быть в списке This link has to be listed in Redirect URI в настройках маркетаin market's settings
После перехода по данной ссылке пользователь проходит авторизацию в системе After following this link, the user is authorized in Ace Stream, после чего перенаправляется на указанный system and then redirected to the specified [REDIRECT_URI].
Если во время авторизации произошла ошибкаIf during authorization an error was occurred, то на parameters error error_description describing the error are sent to [REDIRECT_URI] передаются параметры error error_description, описывающие ошибку.
После успешной авторизации передается параметр After successful authentication parameter <tt>code</tt>is passed: это код подтверждения (this is an authorization code) для получения токена доступа (for getting access_token).
После получения кода сторонний сайт дожен получить After receiving the code third-party site should get <tt>access_token</tt>. Для этого на адрес For this POST-request with the following parameters is sent to <nowiki>https://accounts.acestream.net/oauth/v2/token</nowiki> отправляется POST-запрос с такими переменными:* '''client_id''' - идентификатор маркетаmarket's identifier* '''client_secret''' - секретный ключ маркета secret market key (можно узнать в настйроках маркетаyou can find it out in market's settings)* '''code''' - код подтверждения, полученный ранееconfirmation code obtained earlier* '''grant_type''' - строка string "authorization_code"* '''redirect_uri''' - ссылка, указанная в первом запросеlink specified in the first request
Ответ на данный запрос отправляется в формате Response to this request is sent in JSONformat.
В случае ошибки в ответе присутствует поле In case of an error field <tt>error_description</tt> с описанием ошибкиwith error decription is present in the response.
В случае успешного выполнения в ответе высылается токен доступа в поле If successful, the access token in the field <tt>access_token</tt>is sent in the response.
С помощью токена доступа сторонний сайт имеет возможность получить Using the access token third-party site is able to get e-mail и публичный ключ пользователяand public key of the user. Для этого отправляется For this GET-запрос на адрес request with the following parameters is sent to <nowiki>https://accounts.acestream.net/oauth/api</nowiki> с такими параметрами:* '''method''' - строка string "getUserInfo"* '''access_token''' - полученный ранее токен доступаaccess token obtained earlier
В случае успешного выполнения данного запроса в ответ отправляются данные пользователя в формате If the request was successful, user's data in JSONformat are sent in response:
<nowiki>{
"user": {
0
edits

Navigation menu