| Did you know ... | Search Documentation: |
| Pack bitrix24 -- docs/member-scoped-auth-design.md |
Support Bitrix24 app installations for multiple portals and multiple member_id
contexts without breaking the current single-installation API.
The current implementation stores auth data in one global keyspace:
key -> valuerobot-bitrix flow where install state, access token, refresh token, and
client_endpoint are scoped by member_id.Keep the current global API for backward compatibility and add a second, member-aware layer on top of the same transport.
Add a new persistent store for portal/member auth state:
:- persistent portal_app_info(member_id:atom, key:atom, value:any).
Recommended persisted fields per member_id:
public_base_url
Keep existing app_info/2 untouched for legacy single-portal usage.
Add new predicates in bitrix24_config:
bitrix24_config:portal_app_info(MemberID, 'auth[access_token]', AccessToken).
Add member-aware auth predicates in bitrix24_auth:
Extend api_call/4 options to accept a member context:
bitrix24_rest:api_call(Method, Params, Result, [member(MemberID)]).
When member(MemberID) is present:
bitrix24_auth:check_token(MemberID) from portal_app_info/3` from portal_app_info/3`expired_token, call bitrix24_auth:refresh_token(MemberID)
When the option is absent, keep the current global behavior unchanged.Introduce the new persistent relation and member-aware predicates without changing existing callers.
Teach install flows to store both:
Update app-oriented callers to pass [member(MemberID)] into
api_call/4.
This is the point where robot-bitrix style integrations can safely use
multiple portal contexts.
After all portal-aware callers are migrated, optionally reduce dependency on global auth state for app integrations, while still keeping the global API for simple script-style pack usage.
The member-aware flow should preserve current error shapes:
This design keeps the current pack useful for simple single-installation cases,
but makes multi-portal app integrations possible without forking the transport
stack or duplicating refresh logic outside bitrix24_auth and bitrix24_rest.