mobile_authentication 0.3.1 copy "mobile_authentication: ^0.3.1" to clipboard
mobile_authentication: ^0.3.1 copied to clipboard

Library to pradronize the login method do Senior Sistemas clocking event system

example/mobile_authentication_example.dart

import 'dart:io';

import 'package:http/http.dart' as http_client;
import 'package:mobile_authentication/mobile_authentication_service.dart';

import 'custom_http_client.dart';

void main() async {
  /// Insert valid, updated token to perform the call
  String tokenAcess = '{TOKEN}';

  HttpOverrides.global = MyHttpOverrides();
  http_client.Client httpClient = CustomHttpClient(
    http_client.Client(),
    tokenAcess,
  );

  IMobileAuthenticationService service =
      MobileAuthenticationService(httpClient: httpClient);

  DeviceInfo device = DeviceInfo(
    name: '{NAME}',
    identifier: '{IDENTIFIER}',
    model: '{MODEL}',
  );

  try {
    MobileLoginResponse mobileLoginResponse =
        await service.getMobileLogin(device, Environment.dev, tokenAcess);
    print(mobileLoginResponse.toJson().toString());
  } catch (e) {
    print(e);
  }

  AuthorizationParameter authorizationParameter = AuthorizationParameter(
      resource: 'res://senior.com.br/hcm/pontomobile/administrator',
      action: 'Permitir');
  AuthorizationPermissions authorizationPermissions =
      AuthorizationPermissions(permissions: []);
  authorizationPermissions.permissions.add(authorizationParameter);

  try {
    AuthorizationResponse authorizationResponse = await service
        .getAuthorization(authorizationPermissions, Environment.dev);
    print(authorizationResponse.toJson().toString());
  } catch (e) {
    print(e);
  }
}

/// Custom HttpOverrides class to bypass SSL verification
class MyHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext? context) {
    HttpClient client = super.createHttpClient(context);
    client.badCertificateCallback =
        (X509Certificate cert, String host, int port) => true;
    return client;
  }
}
2
likes
120
pub points
68%
popularity

Publisher

verified publishersenior.com.br

Library to pradronize the login method do Senior Sistemas clocking event system

Repository

Documentation

API reference

License

ISC (LICENSE)

Dependencies

equatable, http, json_annotation

More

Packages that depend on mobile_authentication