User authentication
In order to have peer-to-peer call in application, CallEngine should be intergated and initialized properly Make sure that SdkManager dependencies has been properly initialized before. Note that almost all functionality in engines requires session to be started and then user must be authenticated
it can use different types: phone, email and oauth, here an example of authentication by phone
// use session object to make API calls
// sent request to get confirmation code
val sentCode: TLSentCode =
session.callEnsure(TLSendCode(phone, TLAuthCodeDeliveryTypeSMS(), "en", "")).get()
// authorize with confirmation code
val authorizeAccount = TLAuthorizeAccount(
phone,
sentCode.phoneCodeHash,
"55786", // sms code
""
)
authorization = session.callEnsure(authorizeAccount).get()
// every authorization is constrained to organizations scope
// and authorized-context request should be made with organization id
val orgId = ORG_RID
val orgToken =
authorization?.account?.users?.first { it is TLUserSelf && it.organizationId == orgId }
.let { it as TLUserSelf }.organizationToken
if (orgToken != null) {
// example - how to get user state with org-scoped request
val state: TLUserState = session.callOrgEnsure(orgId, orgToken, TLGetUserState()).get()
isAuthorized = true
}Last updated
