authenticate method

Future<GithubSignInResponse> authenticate(
  1. String code
)

Implementation

Future<GithubSignInResponse> authenticate(String code) async {
  try {
    accessToken = await getAccesToken(code);
    if (accessToken != null) {
      var userData = await getUserData();
      var email = await getEmail();
      return GithubSignInResponse(
        message: "Success",
        status: ResultStatus.success,
        email: email,
        image: userData?['avatar_url'].toString(),
        name: userData?['name'].toString(),
        userName: userData?['login'].toString(),
        id: userData?['id'].toString(),
        allUserData: jsonEncode(userData),
      );
    }
    return GithubSignInResponse(
      message: message,
      status: ResultStatus.error,
    );
  } catch (e) {
    return GithubSignInResponse(
      message: "$message\n\n$e",
      status: ResultStatus.error,
    );
  }
}