getUserInfoByAccessToken static method

Future<Result> getUserInfoByAccessToken(
  1. String accessToken, [
  2. Map? data
])

Token Change user information

Implementation

static Future<Result> getUserInfoByAccessToken(String accessToken,
    [Map? data]) async {
  String url = "https://" + Util.getHost(Authing.config) + "/oidc/me";
  var client = HttpClient();
  HttpClientRequest request = await client.getUrl(Uri.parse(url));

  request.headers.set("Authorization", "Bearer " + accessToken);

  HttpClientResponse response = await request.close();
  var res = await response.transform(utf8.decoder).join();
  Result result = Result();
  if (response.statusCode == 200) {
    result.statusCode = 200;
    result.message = "success";
    result.data = jsonDecode(res);
    // AuthResult authResult = AuthResult(result);
    // authResult.user = await AuthClient.createUser(result);
    // authResult.user =
    //     await User.update(authResult.user ?? User(), data ?? {});
    return result;
  } else {
    result.statusCode = response.statusCode;
    result.message = "getUserInfoByAccessToken failed. " + res;
    return result;
  }
}