コード例 #1
0
 public ExternalAuthController(
     UserManager <ApplicationUser> userManager,
     IUnitOfWork unitOfWork,
     IJwtFactory jwtFactory,
     IOptions <JwtIssuerOptions> jwtOptions,
     IOptions <LinkedInOAuthSettings> linkedInAuthSettingsAccessor,
     IOAuthService oAuthService,
     IUserSignInService userSignInService,
     ILogger <ExternalAuthController> logger
     )
 {
     _userManager          = userManager;
     _unitOfWork           = unitOfWork;
     _jwtFactory           = jwtFactory;
     _jwtOptions           = jwtOptions.Value;
     _linkedInAuthSettings = linkedInAuthSettingsAccessor.Value;
     _oAuthService         = oAuthService;
     _userSignInService    = userSignInService;
     _logger = logger;
 }
コード例 #2
0
        public async Task <LinkedInAccessToken> GetAccessTokenAsync(string authorizationCode, string redirectUri, LinkedInOAuthSettings clientCredentials)
        {
            var dict = new Dictionary <string, string>();

            dict.Add("grant_type", "authorization_code");
            dict.Add("code", authorizationCode);
            dict.Add("redirect_uri", redirectUri);
            dict.Add("client_id", clientCredentials.ClientId);
            dict.Add("client_secret", clientCredentials.ClientSecret);

            var response = await webApiClientInstance.PostAsyncFacade(LinkedInEndpoints.AccessTokenUri, new FormUrlEncodedContent(dict));

            if (response.IsSuccessStatusCode)
            {
                var accessTokenResponseStr = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <LinkedInAccessToken>(accessTokenResponseStr));
            }

            return(null);
        }