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

dart implementation of bupt-auth

bupt-auth-dart #

Dart implementation of BUPT-Auth, a library for authenticating with BUPT services.

参考https://github.com/byrdocs/bupt-auth

使用 #

import 'dart:io';
import 'package:bupt_auth_dart/bupt_auth_dart.dart' as bupt_auth;

void main() async {
  stdout.write('学号: ');
  String buptId = stdin.readLineSync()!.trim();
  stdout.write('密码: ');
  String buptPass = stdin.readLineSync()!.trim();

  try {
    // 尝试登录
    bupt_auth.UserInfo user = await bupt_auth.login(buptId, buptPass);
    print('登录成功: $user');
  } catch (e) {
    if (e is bupt_auth.CaptchaError) {
      print('需要验证码');
      print('\tCaptcha URL: ${e.captchaUrl}');
      print('\tCookie: ${e.cookie}');
      stdout.write('Captcha: ');
      String captcha = stdin.readLineSync()!.trim();
      bupt_auth.UserInfo user = await e.resolve(captcha);
      print('登录成功: $user');
    } else {
      rethrow;
    }
  }
}
0
likes
130
points
25
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

dart implementation of bupt-auth

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

http

More

Packages that depend on bupt_auth_dart