initAccountAuthToken method

Future<UserAccount> initAccountAuthToken(
  1. String code,
  2. String codeVerifier
)

初始化token

Implementation

Future<UserAccount> initAccountAuthToken(String code, String codeVerifier) async {
  final response = await _httpClient.post<String>(
    '/auth/token',
    data: {
      "client_id": _clientId,
      "client_secret": _clientSecret,
      "include_policy": true,
      "grant_type": "authorization_code",
      "code_verifier": codeVerifier,
      'code': code,
      'redirect_uri': 'https://app-api.pixiv.net/web/v1/users/auth/pixiv/callback',
    },
    options: Options(contentType: Headers.formUrlEncodedContentType),
  );

  return UserAccount.fromJson(jsonDecode(response.data!));
}