getCurrentUser method

Future<CurrentUser> getCurrentUser()

Fetches the currently authenticated user.

Throws AccessForbidden if we are not authenticated.

API docs: https://developer.github.com/v3/users/#get-the-authenticated-user

Implementation

Future<CurrentUser> getCurrentUser() => github.getJSON('/user',
    statusCode: StatusCodes.OK,
    fail: (http.Response response) {
      if (response.statusCode == StatusCodes.FORBIDDEN) {
        throw AccessForbidden(github);
      }
    },
    convert: (dynamic i) => CurrentUser.fromJson(i));