authByCode static method
Auth by code #
Implementation
static Future<AuthResult> authByCode(
String code, AuthRequest authRequest) async {
String url = "https://" + Util.getHost(Authing.config) + "/oidc/token";
String body = "client_id=" +
Authing.sAppId +
"&grant_type=authorization_code" +
"&code=" +
code +
"&scope=" +
authRequest.scope +
"&prompt=" +
"consent" +
"&code_verifier=" +
authRequest.codeVerifier +
"&redirect_uri=" +
Uri.encodeComponent(authRequest.redirectUrl);
Result result = await oauthRequest("post", url, body);
AuthResult authResult = AuthResult(result);
if (authResult.statusCode == 200 || authResult.statusCode == 201) {
AuthResult userResult = await AuthClient.getCurrentUser();
authResult.user =
await User.update(userResult.user ?? User(), result.data);
return authResult;
} else {
return authResult;
}
}