public virtual Task<UserInfo> CompleteAuthentication(ISettings settings, string accessToken)
{
try
{
return VerifyToken(GetAppId(settings), accessToken).Then(verifiedToken =>
{
// Build the URL
UriBuilder meUrl = new UriBuilder(FetchUserInfoBaseUrl);
meUrl.Query = AccessTokenQueryParameterName + "=" + verifiedToken;
// Fetch the user's record from the service
HttpClient client = CreateHttpClient();
return client.GetAsync(meUrl.Uri).Then(resp =>
{
resp.EnsureSuccessStatusCode();
return resp.Content.ReadAsStringAsync();
}).Then(json =>
{
return ParseResponse(json);
});
});
}
catch (Exception ex)
{
return TaskHelpers.FromError<UserInfo>(ex);
}
}