ReviewR.Web.Services.Authenticators.Authenticator.CompleteAuthentication C# (CSharp) Method

CompleteAuthentication() public method

public CompleteAuthentication ( ISettings settings, string accessToken ) : Task
settings ISettings
accessToken string
return Task
        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);
            }
        }

Usage Example

Esempio n. 1
0
 protected internal virtual Task<UserInfo> ExchangeToken(string accessToken, Authenticator auth)
 {
     return auth.CompleteAuthentication(Settings, accessToken);
 }