ProcessCallbackAsync() public method

public ProcessCallbackAsync ( ) : Task
return Task
        public async Task<ActionResult> OAuthTokenCallback()
        {
            var ctx = GetOAuthContextCookie();
            var ip = GetEnabledOAuthIdentityProviders().Single(x => x.ID == ctx.IdP);

            var oauth2 = new OAuth2Client(GetProviderTypeFromOAuthProfileTypes(ip.ProviderType.Value), ip.ClientID, ip.ClientSecret);
            var result = await oauth2.ProcessCallbackAsync();
            if (result.Error != null) return View("Error");

            var claims = result.Claims.ToList();
            claims.Add(new Claim(Constants.Claims.IdentityProvider, ip.Name, ClaimValueTypes.String, Constants.InternalIssuer));
            var id = new ClaimsIdentity(claims, "OAuth");
            var cp = new ClaimsPrincipal(id);

            return ProcessOAuthResponse(cp, ctx);
        }
        public async Task<ActionResult> OAuthTokenCallback()
        {
            var ctx = GetOAuthContextCookie();
            var ip = GetEnabledOAuthIdentityProviders().Single(x => x.ID == ctx.IdP);

            var oauth2 = new OAuth2Client(GetProviderTypeFromOAuthProfileTypes(ip.ProviderType.Value), ip.ClientID, ip.ClientSecret);
            var result = await oauth2.ProcessCallbackAsync();
            if (result.Error != null) return View("Error");

            var claims = result.Claims.ToList();
            string[] claimsToRemove = new string[]
            {
                "http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider",
                ClaimTypes.AuthenticationInstant
            };
            
            foreach (var toRemove in claimsToRemove)
            {
                var tmp = claims.Find(x => x.Type == toRemove);
                if (tmp != null) claims.Remove(tmp);
            }
            
            claims.Add(new Claim(Constants.Claims.IdentityProvider, ip.Name, ClaimValueTypes.String, Constants.InternalIssuer));
            var id = new ClaimsIdentity(claims, "OAuth");
            var cp = new ClaimsPrincipal(id);
            
            return ProcessOAuthResponse(cp, ctx);
        }