mcauthlib 1.0.0 copy "mcauthlib: ^1.0.0" to clipboard
mcauthlib: ^1.0.0 copied to clipboard

Mojang's Yggdrasil authentication for Dart.

example/mcauthlib_example.dart

import 'package:mcauthlib/mcauthlib.dart';

void main() async {
  //This example is how to authenticate with this library.

  //First create MojangAuth instance.
  final auth = MojangAuth();

  //Then, create User with authtype keyword.
  //The first parameter is email and the second one is password.
  var user = User.authType("lorem@ipsum.com", "dolorsitamet");

  //await until authentication return map with
  //Response type, clientToken, accessToken, player uuid.
  var result = await auth.authenticate(user);

  //If a request was successful the response type should be
  //ResponseType.success
  //if not, it will return ResponseType.failure with error Type.
  if(result['responseType'] == ResponseType.success){
    user.clientToken = result['clientToken'];
    user.accessToken = result['accessToken'];
  }
}
1
likes
140
points
8
downloads

Publisher

unverified uploader

Weekly Downloads

Mojang's Yggdrasil authentication for Dart.

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

http, json_annotation, path

More

Packages that depend on mcauthlib