public ReportClient( HttpClient httpClient, IOAuthClient oAuthClient) { _httpClient = httpClient; _oAuthClient = oAuthClient; }
public WebApiClient( HttpClient httpClient, IOAuthClient oAuthClient) { _httpClient = httpClient; _oAuthClient = oAuthClient; }
public SecretClient(ILogger logger, IRestClient restClient, IOAuthClient oAuthClient, ICacheClient cacheClient) { this._logger = logger; this._restClient = restClient; this._cacheClient = cacheClient; this._oAuthClient = oAuthClient; }
public AccountControllerTest() { apiClient = A.Fake <IWeeeClient>(); authenticationManager = A.Fake <IAuthenticationManager>(); oauthClient = A.Fake <IOAuthClient>(); userInfoClient = A.Fake <IUserInfoClient>(); externalRouteService = A.Fake <IExternalRouteService>(); }
public AccountControllerTest() { apiClient = A.Fake<IWeeeClient>(); authenticationManager = A.Fake<IAuthenticationManager>(); oauthClient = A.Fake<IOAuthClient>(); userInfoClient = A.Fake<IUserInfoClient>(); externalRouteService = A.Fake<IExternalRouteService>(); }
private void OAuthTest(String platformCode) { String authorizeUrl = String.Empty; if (String.IsNullOrEmpty(platformCode)) { platformCode = "qq"; } //Console.WriteLine("OpenPlatform Request For " + platformCode); //Console.WriteLine(""); IOAuthClient oauthClient = m_oauthClients[platformCode]; oauthClient.Option.State = platformCode; //第一步:获取开放平台授权地址 authorizeUrl = m_oauthClients[platformCode].GetAuthorizeUrl(ResponseType.Code); //Console.WriteLine("Step 1 - OAuth2.0 for Redirect AuthorizeUrl: "); //Console.WriteLine(authorizeUrl); //第二步:打开IE浏览器获取Code Process p = new Process(); ProcessStartInfo psi = new ProcessStartInfo(); psi.Arguments = authorizeUrl; psi.FileName = "C:\\Program Files\\Internet Explorer\\iexplore.exe"; p.StartInfo = psi; p.Start(); //Console.WriteLine(""); //Console.WriteLine("OAuth2.0 Input Server Response Code"); String code = Console.ReadLine(); //第三步:获取开放平台授权令牌 oauthClient = m_oauthClients[platformCode]; AuthToken accessToken = oauthClient.GetAccessTokenByAuthorizationCode(code); if (accessToken != null) { //Console.WriteLine(""); //Console.WriteLine("Step 2 - OAuth2.0 for AccessToken: " + accessToken.AccessToken); ////输出原始响应数据 //Console.WriteLine("GetAccessToken Raw Response : "); //Console.WriteLine(oauthClient.Token.TraceInfo); //第四步:调用开放平台API,获取开放平台用户信息 dynamic oauthProfile = oauthClient.User.GetUserInfo(); ////输出解析出来的用户昵称 //Console.WriteLine(""); //Console.WriteLine("Step 3 - Call Open API UserInfo: "); //Console.WriteLine("UserInfo Nickname: " + oauthClient.Token.User.Nickname); ////输出原始响应数据 //Console.WriteLine("GetUserInfo Raw Response : "); //Console.WriteLine(oauthClient.Token.TraceInfo); } }
public NewUserControllerTests() { oathClient = A.Fake <IOAuthClient>(); weeeClient = A.Fake <IWeeeClient>(); oathClientCredential = A.Fake <IOAuthClientCredentialClient>(); authenticationManager = A.Fake <IAuthenticationManager>(); externalRouteService = A.Fake <IExternalRouteService>(); appConfig = A.Fake <IAppConfiguration>(); }
public AccountController(IOAuthClient oauthClient, IAuthenticationManager authenticationManager, IIwsClient client, IUserInfoClient userInfoClient) { this.oauthClient = oauthClient; this.client = client; this.authenticationManager = authenticationManager; this.userInfoClient = userInfoClient; }
public UserService(RedisTool RedisTool, HouseMapContext context, EmailService emailService, QQOAuthClient authClient, WeChatAppDecrypt weChatAppDecrypt) { _RedisTool = RedisTool; _context = context; _emailService = emailService; _authClient = authClient.GetAPIOAuthClient(); _weChatAppDecrypt = weChatAppDecrypt; }
public string ThirdLogin(string loginType) { String authorizeUrl = String.Empty; IOAuthClient oauthClient = GetOAuthClient(loginType); oauthClient.Option.State = loginType; //第一步:获取开放平台授权地址 authorizeUrl = oauthClient.GetAuthorizeUrl(ResponseType.Code); return(authorizeUrl); }
public UserService(RedisService redisService, UserDapper userDapper, EmailService emailService, QQOAuthClient authClient, WeChatAppDecrypt weChatAppDecrypt) { _redisService = redisService; _userDapper = userDapper; _emailService = emailService; _authClient = authClient.GetAPIOAuthClient(); _weChatAppDecrypt = weChatAppDecrypt; }
public LoginViewModel(IOAuthClient oAuthClient, IAuthenticationService authService, IPlatformServices platformServices) : base(platformServices) { this.oauthClient = oAuthClient; this.authService = authService; this.LoginUri = this.oauthClient.LoginUri; }
public void SetUp() { var apiSettings = new Mock<ISentinelClientSettings>(); apiSettings.Setup(x => x.Url).Returns(new Uri(ConfigurationManager.AppSettings["ApiUrl"])); apiSettings.Setup(x => x.ClientId).Returns("NUnit"); apiSettings.Setup(x => x.ClientSecret).Returns("NUnit"); apiSettings.Setup(x => x.RedirectUri).Returns("http://localhost"); this.client = new SentinelOAuthClient(apiSettings.Object); }
/// <summary> /// 请求获取token /// </summary> /// <param name="oAuthClient">Token客户端</param> /// <returns></returns> protected override Task <TokenResult?> RequestTokenAsync(IOAuthClient oAuthClient) { var options = this.CredentialsOptions.Value; if (options.Endpoint == null) { throw new TokenEndPointNullException(); } return(oAuthClient.RequestTokenAsync(options.Endpoint, options.Credentials)); }
public WebController(UserDataDapper userDataDapper, RedisService redisService, QQOAuthClient qqOAuthClient, UserService userService, EncryptionTools encryptionTools) { _authClient = qqOAuthClient.GetAPIOAuthClient(); _userDataDapper = userDataDapper; _userService = userService; _encryptionTools = encryptionTools; }
public static IOAuthApiEx GetOAuthApiEx(this IOAuthClient client) { var oauthClient = client as OAuthClient; if (oauthClient == null) { throw new InvalidOperationException("Unable to get OAuthApiEx instance."); } return(oauthClient.OAuthApiEx); }
public void SetUp() { var apiSettings = new Mock <ISentinelClientSettings>(); apiSettings.Setup(x => x.Url).Returns(this.server.BaseAddress); apiSettings.Setup(x => x.ClientId).Returns("NUnit"); apiSettings.Setup(x => x.ClientSecret).Returns("aabbccddee"); apiSettings.Setup(x => x.RedirectUri).Returns("http://localhost"); this.client = new SentinelOAuthClient(apiSettings.Object, this.server.Handler); }
public AccountController(UserDataDapper userDataDapper, EmailService emailService, EncryptionTools encryptionTools, UserService userService, QQOAuthClient authClient) { this._userDataDapper = userDataDapper; this._emailService = emailService; this._encryptionTools = encryptionTools; this._userService = userService; _authClient = authClient.GetAPIOAuthClient(); }
public AccountController(IOAuthClient oauthClient, IAuthenticationManager authenticationManager, IIwsClient client, IUserInfoClient userInfoClient, IOAuthClientCredentialClient oauthClientCredentialClient) { this.oauthClient = oauthClient; this.client = client; this.authenticationManager = authenticationManager; this.userInfoClient = userInfoClient; this.oauthClientCredentialClient = oauthClientCredentialClient; }
public AccountController(UserDataDapper userDataDapper, EmailService emailService, EncryptionTools encryptionTools, IOptions <APPConfiguration> configuration ) { this.userDataDapper = userDataDapper; this.emailService = emailService; this.encryptionTools = encryptionTools; this.configuration = configuration.Value; this.authClient = GetOAuthClient(); }
public SpotifyService( ISpotifyTrackRepository spotifyTrackRepository, IOAuthClient oauthClient, IArtistService artistService, Func <SpotifyClientConfig, ISpotifyClient> spotifyClientProvider, Func <ClientCredentialsRequest> clientCredentialsRequestProvider) { this.spotifyTrackRepository = spotifyTrackRepository; this.oauthClient = oauthClient; this.artistService = artistService; this.spotifyClientProvider = spotifyClientProvider; semaphore = new SemaphoreSlim(1, 1); credentialsRequest = clientCredentialsRequestProvider(); }
public LicenseExpirationNoticeTask( INotificationFacade notificationFacade, IOAuthClient oAuthClient, IWebApiClient webApiClient, ApplicationConfiguration applicationConfiguration, IWebHostEnvironment hostingEnvironment, ILogger <LicenseExpirationNoticeTask> logger) { _notificationFacade = notificationFacade; _oAuthClient = oAuthClient; _webApiClient = webApiClient; _applicationConfiguration = applicationConfiguration; _hostingEnvironment = hostingEnvironment; _logger = logger; }
public static IOAuthClient GetOAuthClient(string clientId, string clientSecret, string callbackUrl, AuthType oAuthClientType) { IOAuthClient authToken = null; switch (oAuthClientType) { case AuthType.QQ: authToken = new OAuthClientQQ(clientId, clientSecret, callbackUrl); break; case AuthType.Sina: authToken = new OAuthClientSina(clientId, clientSecret, callbackUrl); break; } return(authToken); }
private static void ConfigureDynamics(IServiceCollection services, ProjectConfiguration project, ProjectResource projectResource, Serilog.ILogger logger) { Debug.Assert(services != null, "Required ServiceCollection is null"); Debug.Assert(project != null, "Required ProjectConfiguration is null"); Debug.Assert(projectResource != null, "Required ProjectResource is null"); Debug.Assert(projectResource.Type == ProjectType.Dynamics, "Project type must be Dynamics"); // the projectResourceKey convention is repeated also in OAuthClientFactory which gets the HttpClient using the same convention, // // {Id}-dynamics-authorization // string projectResourceKey = project.Id + "-dynamics"; // add authorization HttpClient services.AddHttpClient(projectResourceKey + "-authorization", configure => configure.BaseAddress = projectResource.AuthorizationUri) ; // add odata HttpClient // note: I do not like this IoC anti-pattern where we are using the service locator directly, however, // there are many named dependencies. There may be an opportunity to address this in the future var builder = services.AddHttpClient(projectResourceKey, configure => { configure.BaseAddress = projectResource.Resource; }) .AddHttpMessageHandler(serviceProvider => { // build the token service that talk to the OAuth endpoint IOAuthClientFactory oauthClientFactory = serviceProvider.GetRequiredService <IOAuthClientFactory>(); IOAuthClient client = oauthClientFactory.Create(project); ITokenCache <OAuthOptions, Token> tokenCache = serviceProvider.GetRequiredService <ITokenCache <OAuthOptions, Token> >(); ITokenService tokenService = new OAuthTokenService(client, tokenCache); var handler = new TokenAuthorizationHandler(tokenService, CreateOAuthOptions(projectResource)); return(handler); }); var apiGatewayHost = projectResource.ApiGatewayHost; var apiGatewayPolicy = projectResource.ApiGatewayPolicy; if (!string.IsNullOrEmpty(apiGatewayHost) && !string.IsNullOrEmpty(apiGatewayPolicy)) { // add the ApiGatewayHandler logger.Information("Using {@ApiGateway} for {Resource}", new { Host = apiGatewayHost, Policy = apiGatewayPolicy }, projectResource.Resource); builder.AddHttpMessageHandler(() => new ApiGatewayHandler(apiGatewayHost, apiGatewayPolicy)); } }
public DailyReportTask( INotificationFacade notificationFacade, IWebHostEnvironment hostingEnvironment, ILogger <DailyReportTask> logger, IWebApiClient webApiClient, IOAuthClient oAuthClient, IReportClient reportClient, IStatsRepository statsRepository) { _notificationFacade = notificationFacade; _hostingEnvironment = hostingEnvironment; _logger = logger; _webApiClient = webApiClient; _oAuthClient = oAuthClient; _reportClient = reportClient; _statsRepository = statsRepository; }
public IOAuthClient GetOAuthClient(string loginType) { #region 初始化参数 string ClientId = string.Empty, ClientScrert = string.Empty, CallbackUrl = string.Empty; if (loginType == "qq") { ClientId = ConfigHelper.Custom.OAuthQQ.ClientId; //.GetAppSettings("OAuth_QQ_ClientId"); ClientScrert = ConfigHelper.Custom.OAuthQQ.ClientScrert; //.GetAppSettings("OAuth_QQ_ClientScrert"); CallbackUrl = ConfigHelper.Custom.OAuthQQ.CallbackUrl; //.GetAppSettings("OAuth_QQ_CallbackUrl"); } else if (loginType == "sinaweibo") { ClientId = ConfigHelper.Custom.OAuthSina.ClientId; //.GetAppSettings("OAuth_Sina_ClientId"); ClientScrert = ConfigHelper.Custom.OAuthSina.ClientScrert; //.GetAppSettings("OAuth_Sina_ClientScrert"); CallbackUrl = ConfigHelper.Custom.OAuthSina.CallbackUrl; //.GetAppSettings("OAuth_Sina_CallbackUrl"); } else { return(null); } var iswww = Request.Url.AbsoluteUri.Substring(Request.Url.AbsoluteUri.IndexOf("//") + 2, 3) == "www"; if (iswww) { CallbackUrl = "http://www." + CallbackUrl; } else { CallbackUrl = "http://" + CallbackUrl; } #endregion Dictionary <String, IOAuthClient> m_oauthClients = new Dictionary <string, IOAuthClient>(); if (loginType == "qq") { m_oauthClients[loginType] = new GeRenXing.OpenPlatform.OAuthClient.TencentQQClient(ClientId, ClientScrert, CallbackUrl); } else if (loginType == "sinaweibo") { m_oauthClients[loginType] = new GeRenXing.OpenPlatform.OAuthClient.SinaWeiBoClient(ClientId, ClientScrert, CallbackUrl); } IOAuthClient oauthClient = m_oauthClients[loginType]; return(oauthClient); }
/// <summary> /// 刷新token /// </summary> /// <param name="oAuthClient">Token客户端</param> /// <param name="refresh_token">刷新token</param> /// <returns></returns> protected override Task <TokenResult?> RefreshTokenAsync(IOAuthClient oAuthClient, string?refresh_token) { var options = this.CredentialsOptions.Value; if (options.Endpoint == null) { throw new TokenEndPointNullException(); } var credentials = new RefreshTokenCredentials { Client_id = options.Credentials.Client_id, Client_secret = options.Credentials.Client_secret, Extra = options.Credentials.Extra, Refresh_token = refresh_token }; return(oAuthClient.RefreshTokenAsync(options.Endpoint, credentials)); }
private async Task <Tuple <ProjectResource, Exception> > GetOAuthAccessTokenAsync(ProjectConfiguration project, ProjectResource resource) { if (project == null) { throw new ArgumentNullException(nameof(project)); } if (resource == null) { throw new ArgumentNullException(nameof(resource)); } var options = new OAuthOptions { AuthorizationUri = resource.AuthorizationUri, ClientId = resource.ClientId, ClientSecret = resource.ClientSecret, Username = resource.Username, Password = resource.Password, Resource = resource.Resource }; try { IOAuthClient oAuthClient = _oAuthClientFactory.Create(project); ITokenCache <OAuthOptions, Token> tokenCache = _serviceProvider.GetRequiredService <ITokenCache <OAuthOptions, Token> >(); ITokenService tokenService = new OAuthTokenService(oAuthClient, tokenCache); // IOAuthClient does not cache tokens var token = await tokenService.GetTokenAsync(options, CancellationToken.None); return(Tuple.Create(resource, _noException)); } catch (Exception e) { return(Tuple.Create(resource, e)); } }
public Engine( IQueue queue, INotifier notifier, IProductAnalyticsAPIClient productAnalyticsAPIClient, ICache persister, IUDRData udrData, IHttpClientFactory httpClientFactory, IOAuthClient oauthClient, IEncryptedEnvVariable decryptVariable, ISlackAPI slack, IHeadtoHeadAPIClient headToHeadAPIClient ) { this.queue = queue ?? throw new ArgumentNullException("queue"); this.notifier = notifier ?? throw new ArgumentNullException("notifier"); this.productAnalyticsAPIClient = productAnalyticsAPIClient ?? throw new ArgumentNullException("productAnalyticsAPIClient"); this.persister = persister ?? throw new ArgumentNullException("persister"); this.udrData = udrData ?? throw new ArgumentNullException("udrData"); this.httpClientFactory = httpClientFactory ?? throw new ArgumentNullException("httpClientFactory"); this.oauthClient = oauthClient ?? throw new ArgumentNullException("oauthClient"); this.decryptVariable = decryptVariable ?? throw new ArgumentNullException("decryptVariable"); this.slack = slack ?? throw new ArgumentNullException("slack"); this.headToHeadAPIClient = headToHeadAPIClient ?? throw new ArgumentNullException("headToHeadAPIClient"); }
public OAuthTokenService(IOAuthClient client, ITokenCache tokenCache) { _client = client ?? throw new ArgumentNullException(nameof(client)); _tokenCache = tokenCache ?? throw new ArgumentNullException(nameof(tokenCache)); }
/// <summary> /// Initializes a new instance of the <see cref="SentinelLoginController" /> class. /// </summary> /// <param name="oauthClient">The oauth client.</param> /// <param name="log">The log.</param> protected SentinelLoginController(IOAuthClient oauthClient, ILog log) { this.oauthClient = oauthClient; this.log = log; }
public SinaWeiBoUserImpl(IOAuthClient oauth) { this.oauth = oauth; }
public TencentQQUserImpl(IOAuthClient oauth) { this.oauth = oauth; }
public TaoBaoUserImpl(IOAuthClient oauth) { this.oauth = oauth; }
public AccountController(UserService userService, QQOAuthClient authClient) { this._userService = userService; _authClient = authClient.GetAPIOAuthClient(); }
public TaoBaoUserImpl(IOAuthClient oauth) { this.oauth = oauth; }