Authentication
SDK authentication allows you to authenticate a user in the App and perform the SDK operations from this user. In CrypteriumAPI class we have implemented  a method for authentication. 
authorize
To authenticate a user, you need to get a user authentication token.  Send an "authorize user" API request (see User account). Once you have a JSON response from the backend, initialize an Access object by matching the fields from the JSON file.
Access
struct Access {
  var access_token: Sring
  var expires_in: Decimal
  var refresh_token: String
  var scope: String
  var token_type: String
}
class Access(
  val access_token: Sring,
  val expires_in: Int,
  val refresh_token: String,
  val scope: String,
  val token_type: String
)
Pass the Access object as a parameter to the authorize method. The method calls a completion closure.
The argument of the closure is an object of the CRPTAuthorizationResult type (SignInResult for Android). 
CrypteriumAPI.authorize(access: Access, completion: (CRPTAuthorizationResult) -> Void)
enum CRPTAuthorizationResult {
  case success()
  case failure(CRPTError)
}
auth: ICrypteriumAuth = CrypteriumAPI.auth()
  
auth.authorize(access: Access, completion: (SignInResult) -> Unit)
  
sealed class SignInResult {
    object success : SignInResult()
    data class failure(val response: CRPTErrorResponse) : SignInResult()
}
Income parameters
| parameter name | parameter type | description | 
|---|---|---|
| access | Access | object containing authorization info from the backend JSON file | 
CRPTAuthorizationResult 
The CRPTAuthorizationResult (SignInResult) object value is attached to a success or a failure case:
| case | variable | variable type | description | 
|---|---|---|---|
| success | - | - | authentication passed successfully | 
| failure | error | CRPTError | error details | 
Updated over 3 years ago
