Open main menu

Ace Stream Wiki β

Changes

OAuth2/en

1,310 bytes removed, 09: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:
Реселлер размещает на своем сайте ссылку с названием вида "Войти через Ace Stream", которая ведет сюда:
<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
* '''[CLIENT_ID]''' - идентификатор маркета, который реселлер может узнать в настройках своего маркета
* '''[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
* '''[REDIRECT_URI]''' - ссылка, на который будет перенаправлен пользователь после успешной авторизации. Данная ссылка должна быть в списке Redirect URI в настройках маркета
 
After following this link, the user is authorized in Ace Stream system and then redirected to the specified [REDIRECT_URI].
После перехода по данной ссылке пользователь проходит авторизацию в системе Ace Stream, после чего перенаправляется на указанный [REDIRECT_URI].
 
If during authorization an error was occurred, parameters error error_description describing the error are sent to [REDIRECT_URI].
Если во время авторизации произошла ошибка, то на [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 JSON format.
Ответ на данный запрос отправляется в формате JSON.
 
В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.
В случае успешного выполнения в ответе высылается токен доступа в поле <tt>access_token</tt>
 
С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 JSON format are sent in response:
В случае успешного выполнения данного запроса в ответ отправляются данные пользователя в формате JSON:
<nowiki>{
"user": {