Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Задокументировать структуры данных для события «установка приложения» #30

Open
mesilov opened this issue Dec 22, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@mesilov
Copy link
Owner

mesilov commented Dec 22, 2024

Description

Задокументировать структуры данных для события установка приложения:

  • установщик есть
  • установщика нет, но зарегистрирован обработчик

Фиксируем:

  • какие данные приходят
  • что нужно прокинуть в useCase
  • проверить, меняется ли applicationToken если это «перустановка приложения»
  • проверить, меняется ли applicationToken если это «установка приложения другим админом»

Example

No response

@mesilov mesilov added the enhancement New feature or request label Dec 22, 2024
@mesilov mesilov added this to the Bitrix24Accounts milestone Dec 22, 2024
@mesilov mesilov self-assigned this Dec 22, 2024
@mesilov
Copy link
Owner Author

mesilov commented Jan 12, 2025

Случай «есть установщик»

на install.php идёт POST-запрос с multipart form data

POST /install.php?DOMAIN=bitrix24-php-sdk-playground.bitrix24.ru&PROTOCOL=1&LANG=en&APP_SID=b3ab009e190a6f9f09103f74f8d03747 HTTP/1.1
Host: 8629-94-143-197-212.ngrok-free.app
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Content-Length: 364
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-US,en;q=0.9,uk;q=0.8,ru;q=0.7
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Dnt: 1
Origin: https://bitrix24-php-sdk-playground.bitrix24.ru
Priority: u=0, i
Referer: https://bitrix24-php-sdk-playground.bitrix24.ru/
Sec-Ch-Ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Sec-Fetch-Dest: iframe
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Upgrade-Insecure-Requests: 1
X-Forwarded-For: 94.143.197.212
X-Forwarded-Host: 8629-94-143-197-212.ngrok-free.app
X-Forwarded-Proto: https

AUTH_ID=9ae383670074e4880058f18a00000001302a07e474becf9d73780b391dc4b314877f87&AUTH_EXPIRES=3600&REFRESH_ID=8a62ab670074e4880058f18a00000001302a0724266f953e4b9bcaa27c1371ce0cff69&member_id=010b6886ebc205e43ae65000ee00addb&status=L&PLACEMENT=DEFAULT&PLACEMENT_OPTIONS=%7B%22IFRAME%22%3A%22Y%22%2C%22IFRAME_TYPE%22%3A%22SIDE_SLIDER%22%2C%22any%22%3A%2244%5C%2F%22%7D

Query Params

APP_SID	b3ab009e190a6f9f09103f74f8d03747
DOMAIN	bitrix24-php-sdk-playground.bitrix24.ru
LANG	en
PROTOCOL	1

Form Params

364 bytes application/x-www-form-urlencoded
Form Params
AUTH_EXPIRES	3600
AUTH_ID	9ae383670074e4880058f18a00000001302a07e474becf9d73780b391dc4b314877f87
member_id	010b6886ebc205e43ae65000ee00addb
PLACEMENT	DEFAULT
PLACEMENT_OPTIONS	{"IFRAME":"Y","IFRAME_TYPE":"SIDE_SLIDER","any":"44\/"}
REFRESH_ID	8a62ab670074e4880058f18a00000001302a0724266f953e4b9bcaa27c1371ce0cff69
status	L

@mesilov
Copy link
Owner Author

mesilov commented Jan 12, 2025

Обработчик события ONAPPINSTALL

POST /event-handler.php HTTP/1.1
Host: 8629-94-143-197-212.ngrok-free.app
User-Agent: Bitrix24 Webhook Engine
Content-Length: 783
Accept-Encoding: gzip
Content-Type: application/x-www-form-urlencoded
X-Forwarded-For: 195.208.184.200
X-Forwarded-Host: 8629-94-143-197-212.ngrok-free.app
X-Forwarded-Proto: https

event=ONAPPINSTALL&event_handler_id=104&data%5BVERSION%5D=1&data%5BACTIVE%5D=Y&data%5BINSTALLED%5D=Y&data%5BLANGUAGE_ID%5D=ru&ts=1736694648&auth%5Baccess_token%5D=88e983670074e4980058f18a00000001000007fdde4e24b005701ce19e6c48b8e8f8ea&auth%5Bexpires%5D=1736698248&auth%5Bexpires_in%5D=3600&auth%5Bscope%5D=crm%2Cplacement&auth%5Bdomain%5D=bitrix24-php-sdk-playground.bitrix24.ru&auth%5Bserver_endpoint%5D=https%3A%2F%2Foauth.bitrix.info%2Frest%2F&auth%5Bstatus%5D=L&auth%5Bclient_endpoint%5D=https%3A%2F%2Fbitrix24-php-sdk-playground.bitrix24.ru%2Frest%2F&auth%5Bmember_id%5D=010b6886ebc205e43ae65000ee00addb&auth%5Buser_id%5D=1&auth%5Brefresh_token%5D=7868ab670074e4980058f18a00000001000007c6050422e401331794a0d8f50a060aca&auth%5Bapplication_token%5D=2a32061c81c282fd6fb2b23654d76319

Form Params

auth[access_token]	88e983670074e4980058f18a00000001000007fdde4e24b005701ce19e6c48b8e8f8ea
auth[application_token]	2a32061c81c282fd6fb2b23654d76319
auth[client_endpoint]	https://bitrix24-php-sdk-playground.bitrix24.ru/rest/
auth[domain]	bitrix24-php-sdk-playground.bitrix24.ru
auth[expires_in]	3600
auth[expires]	1736698248
auth[member_id]	010b6886ebc205e43ae65000ee00addb
auth[refresh_token]	7868ab670074e4980058f18a00000001000007c6050422e401331794a0d8f50a060aca
auth[scope]	crm,placement
auth[server_endpoint]	https://oauth.bitrix.info/rest/
auth[status]	L
auth[user_id]	1
data[ACTIVE]	Y
data[INSTALLED]	Y
data[LANGUAGE_ID]	ru
data[VERSION]	1
event	ONAPPINSTALL
event_handler_id	104
ts	1736694648

@mesilov
Copy link
Owner Author

mesilov commented Jan 12, 2025

Если приложение без UI, то идёт POST-запрос на установщик.
Form Params

auth[access_token]	7beb83670074e4a80058f18a000000010000079c041b262f7e1a7930c18320d6e81bd2
auth[application_token]	74fc215d183db91a48efc80f8f4d9622
auth[client_endpoint]	https://bitrix24-php-sdk-playground.bitrix24.ru/rest/
auth[domain]	bitrix24-php-sdk-playground.bitrix24.ru
auth[expires_in]	3600
auth[expires]	1736698747
auth[member_id]	010b6886ebc205e43ae65000ee00addb
auth[refresh_token]	6b6aab670074e4a80058f18a000000010000076fa1006447a729b1cd6617390b489c55
auth[scope]	crm,placement
auth[server_endpoint]	https://oauth.bitrix.info/rest/
auth[status]	L
auth[user_id]	1
data[ACTIVE]	Y
data[INSTALLED]	Y
data[LANGUAGE_ID]	ru
data[VERSION]	1
event	ONAPPINSTALL
event_handler_id	108
ts	1736695146

@camaxtly
Copy link
Collaborator

Проверить вариант, когда приложение без интерфейса и нет регистрации обработчика.

@mesilov
Copy link
Owner Author

mesilov commented Jan 12, 2025

Вариант нет интерфейса и не регистрируется обработчик установки.
Тогда на install.php прилетает POST-запрос

Form Params
auth[access_token]	412084670074e4a80058f18a00000001000007c8115b6c79111393a6578ce0c5efbc93
auth[application_token]	74fc215d183db91a48efc80f8f4d9622
auth[client_endpoint]	https://bitrix24-php-sdk-playground.bitrix24.ru/rest/
auth[domain]	bitrix24-php-sdk-playground.bitrix24.ru
auth[expires_in]	3600
auth[expires]	1736712257
auth[member_id]	010b6886ebc205e43ae65000ee00addb
auth[refresh_token]	319fab670074e4a80058f18a00000001000007c356c785d13d16210d97c4df9985371b
auth[scope]	crm,placement
auth[server_endpoint]	https://oauth.bitrix.info/rest/
auth[status]	L
auth[user_id]	1
data[ACTIVE]	Y
data[INSTALLED]	Y
data[LANGUAGE_ID]	ru
data[VERSION]	1
event	ONAPPINSTALL
event_handler_id	108
ts	1736708657

@mesilov
Copy link
Owner Author

mesilov commented Jan 12, 2025

Вариант: приложение содержит инсталлятр, но не регистрирует отдельный обработчик события ONAPPINSTALL

  1. POST-запрос на инсталлятор в момент загрузки iframe
Query Params
APP_SID	cbe236c071656db95fc2b5ca3fa3c014
DOMAIN	bitrix24-php-sdk-playground.bitrix24.ru
LANG	en
PROTOCOL	1
299 bytes application/x-www-form-urlencoded
Form Params
AUTH_EXPIRES	3600
AUTH_ID	1b2184670074e4a80058f18a00000001302a0700cea9a7985f94721c4d5aeb9c7ed954
member_id	010b6886ebc205e43ae65000ee00addb
PLACEMENT	DEFAULT
PLACEMENT_OPTIONS	{"any":"48\/"}
REFRESH_ID	0ba0ab670074e4a80058f18a00000001302a0705f26237d73717147f546bd09151f32b
status	L
  1. финализируем установку приложения на JS

    const $b24 = await B24Js.initializeB24Frame();
    $b24.installFinish();

  2. получаем post-запрос на эндпоинт install.php который отвечает за загрузку iframe

Form Params
auth[access_token]	1e2184670074e4a80058f18a00000001000007e245fd6e0612851b1190a6654f12daa0
auth[application_token]	74fc215d183db91a48efc80f8f4d9622
auth[client_endpoint]	https://bitrix24-php-sdk-playground.bitrix24.ru/rest/
auth[domain]	bitrix24-php-sdk-playground.bitrix24.ru
auth[expires_in]	3600
auth[expires]	1736712478
auth[member_id]	010b6886ebc205e43ae65000ee00addb
auth[refresh_token]	0ea0ab670074e4a80058f18a00000001000007528c451d443c9c6a4583cf0a482b5eb8
auth[scope]	crm,placement,bizproc
auth[server_endpoint]	https://oauth.bitrix.info/rest/
auth[status]	L
auth[user_id]	1
data[ACTIVE]	Y
data[INSTALLED]	Y
data[LANGUAGE_ID]	ru
data[VERSION]	1
event	ONAPPINSTALL
event_handler_id	108
ts	1736708878

@mesilov
Copy link
Owner Author

mesilov commented Jan 12, 2025

Вариант: приложение содержит инсталлятр, и регистрирует отдельный обработчик события ONAPPINSTALL

1. POST-запрос с загрузкой iframe POST /install.php

Query Params
APP_SID	0da98d028367e6e2d24c69f960f6c762
DOMAIN	bitrix24-php-sdk-playground.bitrix24.ru
LANG	en
PROTOCOL	1
application/x-www-form-urlencoded
Form Params
AUTH_EXPIRES	3600
AUTH_ID	992384670074e4a80058f18a00000001302a0789d2d8687dc879053268811ac4be2f9e
member_id	010b6886ebc205e43ae65000ee00addb
PLACEMENT	DEFAULT
PLACEMENT_OPTIONS	{"any":"48\/"}
REFRESH_ID	89a2ab670074e4a80058f18a00000001302a074f79915b7432d3b8966d3e8ccbffc288
status	L

2. POST /event-handler.php - отдельный эндпоинт по обработке событий от Б24

application/x-www-form-urlencoded
Form Params
auth[access_token]	a22384670074e4a80058f18a000000010000078c56df763e16392bddbc52e2676639f8
auth[application_token]	74fc215d183db91a48efc80f8f4d9622
auth[client_endpoint]	https://bitrix24-php-sdk-playground.bitrix24.ru/rest/
auth[domain]	bitrix24-php-sdk-playground.bitrix24.ru
auth[expires_in]	3600
auth[expires]	1736713122
auth[member_id]	010b6886ebc205e43ae65000ee00addb
auth[refresh_token]	92a2ab670074e4a80058f18a00000001000007199c96a46740c33502b73a14057218b3
auth[scope]	crm,placement,bizproc
auth[server_endpoint]	https://oauth.bitrix.info/rest/
auth[status]	L
auth[user_id]	1
data[ACTIVE]	Y
data[INSTALLED]	Y
data[LANGUAGE_ID]	ru
data[VERSION]	1
event	ONAPPINSTALL
event_handler_id	110
ts	1736709522

3. POST-запрос на install.php

application/x-www-form-urlencoded
Form Params
auth[access_token]	a22384670074e4a80058f18a000000010000078c56df763e16392bddbc52e2676639f8
auth[application_token]	74fc215d183db91a48efc80f8f4d9622
auth[client_endpoint]	https://bitrix24-php-sdk-playground.bitrix24.ru/rest/
auth[domain]	bitrix24-php-sdk-playground.bitrix24.ru
auth[expires_in]	3600
auth[expires]	1736713122
auth[member_id]	010b6886ebc205e43ae65000ee00addb
auth[refresh_token]	92a2ab670074e4a80058f18a00000001000007199c96a46740c33502b73a14057218b3
auth[scope]	crm,placement,bizproc
auth[server_endpoint]	https://oauth.bitrix.info/rest/
auth[status]	L
auth[user_id]	1
data[ACTIVE]	Y
data[INSTALLED]	Y
data[LANGUAGE_ID]	ru
data[VERSION]	1
event	ONAPPINSTALL
event_handler_id	108
ts	1736709522

4. POST /index.php - загрузка основного плейсмента приложения

APP_SID	522ce54bff11393d7d84a4f7fe28bd79
DOMAIN	bitrix24-php-sdk-playground.bitrix24.ru
LANG	en
PROTOCOL	1
application/x-www-form-urlencoded
Form Params
AUTH_EXPIRES	3600
AUTH_ID	a52384670074e4a80058f18a00000001302a077feb16bd05eae704f19efb516b27e0b1
member_id	010b6886ebc205e43ae65000ee00addb
PLACEMENT	DEFAULT
PLACEMENT_OPTIONS	{"install_finished":"Y","any":"48\/"}
REFRESH_ID	95a2ab670074e4a80058f18a00000001302a079c21ed7b1bdb1fab5401386d7ca11fec
status	L

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants