/// <summary> /// /// </summary> /// <param name="reader"></param> /// <returns></returns> internal static ApplicationCredentials GetApplicationCredentials(XmlDocument xml, bool sandbox) { string appId; string appKey; if (sandbox) { appId = GetDataConfiguration(xml, PagSeguroConfigSerializer.SandboxAppId); appKey = GetDataConfiguration(xml, PagSeguroConfigSerializer.SandboxAppKey); } else { appId = GetDataConfiguration(xml, PagSeguroConfigSerializer.AppId); appKey = GetDataConfiguration(xml, PagSeguroConfigSerializer.AppKey); } try { ApplicationCredentials credential = new ApplicationCredentials(appId, appKey); return(credential); } catch (System.Exception) { throw new ArgumentException("To use credentials from config.properties file you must " + "configure the properties credential appId and credential appKey."); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval code for your transaction String authorizationCode = "FD455B5830A54DD58669D361932870E4"; try { ApplicationCredentials credentials = PagSeguroConfiguration.ApplicationCredentials(isSandbox); AuthorizationSummary result = AuthorizationSearchService.SearchByCode(credentials, authorizationCode); Console.WriteLine(result); Console.ReadKey(); } catch (WebException exception) { Console.WriteLine(exception.Message + "\n"); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); String nofiticationCode = "B071CC714E044E04389CC4606FBEFAA3A1BD"; try { ApplicationCredentials credentials = PagSeguroConfiguration.GetApplicationCredentials(isSandbox); // TODO: Substitute the code below with a notification code for your authorization. // You receive this notification code through a post on the URL that you specify AuthorizationSummary authorization = NotificationService.CheckAuthorization(credentials, nofiticationCode); Console.WriteLine(authorization); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
public Auth.Models.ValidateClientResult ValidateClient(AuthTokenParameters authTokenParameters, OAuth10aStateManager oAuth10AStateManager) { TaskTrackerDalForAuth taskTrackerDalForAuth = new TaskTrackerDalForAuth(); var authClientConfig = taskTrackerDalForAuth.GetClientConfig(authTokenParameters.BaseUrl); authClientConfig.Password = authTokenParameters.Password; if (!authClientConfig.IsPasswordMatched) { return new Auth.Models.ValidateClientResult() { Status = false } } ; var JiraApplicationCredentials = new ApplicationCredentials { ConsumerKey = authClientConfig.ConsumerKey, ConsumerSecret = authClientConfig.ConsumerSecretKey.ToXmlString(true) }; var callback = authTokenParameters.RequestUrl.GetLeftPart(UriPartial.Authority) + "/JiraConnect/Callback?baseUrl=" + authTokenParameters.BaseUrl + "&callbackUrl=" + authTokenParameters.CallbackUrl + "&authClientConfigId=" + authClientConfig.Id; var JiraOAuth1AProvider = new JIRAOAuth1aProvider(authTokenParameters.BaseUrl); var authorizationUri = OAuth1aProcess.GetAuthorizationUri(JiraOAuth1AProvider, JiraApplicationCredentials, callback, oAuth10AStateManager); authorizationUri.Wait(); return(new Auth.Models.ValidateClientResult() { Status = true, RedirectionUrl = authorizationUri.Result.AbsoluteUri }); }
public bool ValidateUserActionAndGenerateUserSession(AuthTokenParameters authTokenParameters, OAuth10aStateManager oAuth10AStateManager) { TaskTrackerDalForAuth taskTrackerDalForAuth = new TaskTrackerDalForAuth(); var authClientConfig = taskTrackerDalForAuth.GetClientConfig(authTokenParameters.BaseUrl); var JiraApplicationCredentials = new ApplicationCredentials { ConsumerKey = authClientConfig.ConsumerKey, ConsumerSecret = authClientConfig.ConsumerSecretKey.ToXmlString(true) }; var JiraOAuth1AProvider = new JIRAOAuth1aProvider(authTokenParameters.BaseUrl); var processUserResponse = OAuth1aProcess.ProcessUserResponse(JiraOAuth1AProvider, JiraApplicationCredentials, authTokenParameters.RequestUrl, oAuth10AStateManager); processUserResponse.Wait(); AccessTokenInfo accessTokenInfo = new AccessTokenInfo() { AccessToken = processUserResponse.Result.AllParameters["oauth_token"], AccessTokenSecret = processUserResponse.Result.AllParameters["oauth_token_secret"], }; if (!taskTrackerDalForAuth.SaveUserSession(authTokenParameters.AuthClientConfigId, accessTokenInfo)) { authTokenParameters.AuthClientConfigId = 0; } return(true); }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval code for your transaction String authorizationCode = "(ADD-TOKEN-HERE)"; try { ApplicationCredentials credentials = PagSeguroConfiguration.GetApplicationCredentials(isSandbox); AuthorizationSummary result = AuthorizationSearchService.SearchByCode(credentials, authorizationCode); } catch (WebException exception) { } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid date interval for your authorization DateTime initialDate = new DateTime(2015, 09, 01, 08, 50, 0); DateTime finalDate = new DateTime(2015, 09, 24, 08, 50, 0); int maxPageResults = 10; int pageNumber = 1; try { ApplicationCredentials credentials = PagSeguroConfiguration.GetApplicationCredentials(isSandbox); AuthorizationSearchResult result = AuthorizationSearchService.SearchByDate(credentials, initialDate, finalDate, pageNumber, maxPageResults); } catch (WebException exception) { } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
public FitbitClient(ApplicationCredentials applicationCredentials) { if (!applicationCredentials.IsValid()) { //TODO throw Exception } this.Authentication = new Authentication(applicationCredentials); this.HeartRate = new HeartRate(Authentication); }
private static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AuthorizationRequest authorization = new AuthorizationRequest { Reference = "REF1234", RedirectURL = "http://www.lojamodelo.com.br/redirect", NotificationURL = "http://www.lojamodelo.com.br/notification" }; authorization.addPermission(PermissionType.CREATE_CHECKOUTS); authorization.addPermission(PermissionType.DIRECT_PAYMENT); authorization.addPermission(PermissionType.MANAGE_PAYMENT_PRE_APPROVALS); authorization.addPermission(PermissionType.RECEIVE_TRANSACTION_NOTIFICATIONS); authorization.addPermission(PermissionType.SEARCH_TRANSACTIONS); try { ApplicationCredentials credentials = PagSeguroConfiguration.ApplicationCredentials(isSandbox); string result = authorization.Register(credentials); Console.WriteLine("URL da autorização: " + result); Console.ReadKey(); } catch (WebException exception) { Console.WriteLine(exception.Message + "\n"); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
public JiraConnectController() { var consumerSecret = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmoGNjGeQmpAWjwAbMhPJRj+VW84iN7ZR4LF+FbiCxTw2eIVK5kSXQENZoCDHA0GOGDKhkCUJuxwS7+TLBSMG1PRjPqAWQTuC3FvuO1byowLlDxNqhHrwStaMN5KWzm2/V/npfgkHAqn8/rw2V6LC9HBwKwBVIhMS2HFu4GoISc + N5O5ZYwRBinZTt7kaDRv7X73JW8BsAorzG54fTGEfMRU2o/JPbj5VXvME3eGo0X/XyLtECN1Ff0ovk/6X7ZaN5PwYXe9dZcyANYlA6w91QlrVJyziVb1TwVvpmSPxL9B+NlCg3JdBDyzOIwHXnxhi2naRxOoBWshMLX4f4yfhlAgMBAAECggEAVePbF1xjRJ/L4Gq9lnL5TZ21BCsourA6le+ZlXf9Fii/xkE7GTh+m0/ylVGUA+XnR1QDAP3c5qlkAVklFojggQHrZi8gHxDpuLb6GNiIFRyy4wH4CJGFNMe4MxMnbvuynEY+4jiMmDnKuhMMF7gIUpLIyanVzrnRhGX9yVqwrb2F3PtVhf/gK0Yib93vsCxJ+Pk4eG88vIt+YEpEZq9mleN8L5M5t/1yBSxVtHIZ/KcXIa1Q/C7AVdbNwNbUi7hQwTOg3RFC1cWwOTJu+0sKIKPs9WsZmo6st+dEde4GNHae07/eL44uYZ+HUE3Z+lcjyNkQHbin5HVG8t/idaSlQQKBgQDYeSr474cJx3SKSPG6Lncz812ibQiirt+5pqsuYlwvWBCjWaAb1H+3YR2/9AfLxBK2hGbbUU1DOvdqi3yOQE742ZhQppDaXOkbwn6ZjnS9GFKdsTHRp/DSafwvuM1zT9BRs1sgTNCGEbzh4PxtJlRn4dht1NZ0fOeymB/IJWgKiQKBgQDFDS5RGwqZ9YxkL6Vb7BV6jnWUq+c39/nTEWDDlfWaWKLss03ox22jG6EewEgHIW/Zvc0nOYRuKvxLcMmK3eU1eK6mZqvo4b1GPqdUqUr6PcRn6acvr8rAAiJBz1ZfHs9/JP9JfA4px0CVlfa6mD3bNRhxWYBkFJ4FBy4wRYtX/QKBgEVv6IbdXnWWkx1gdJmCGh6B7AET9HcqnP0SJ0rDpkpRd1TOhPsoWKdb8Y0HHBESneYJ5mxnUd9E5OQ6RgPjQPG16pPEOiaxMt0CsFVVSsD1Mlr+4bocorT75jbwkoZwjaQHYi2kNicrPWk/H/lrGBwSZ7gjU38eKbwx68/pn8vxAoGAY3yEJe7BK3oNp4dmtUI8lePW+XjRBDDusOHVOOo9Ve/qUhc0/pGxiOgqMJxjwTXggs6RBXzEn9qUBoKrPrFJR/XmN50erjVKmmyHjvbqI+2Le+s7vZfDha2OHivQL7YejNLhEPjRLcarlNph91Nl54anEJNffyfpoCA/8Z8q+wECgYEAvaZY1n3I0Fgx5yoXTHEIQDCT8FTcju2VlkW+mBL9uMwnLtdFzNIwwXrIZgiDJhl+rzecMJieqU4FaoWIUq72+iO8LVeFyauvXRuvhx6k6eh/pPbX6EOOigZoF3yIg/XZbnmmn89NUyQm1fvQQtnWOSosb595CBmny5llYZs57p4="; var secretArray = Convert.FromBase64String(consumerSecret); var key = opensslkey.DecodePrivateKeyInfo(secretArray); var baseUrl = "http://172.25.121.176:8080"; JiraApplicationCredentials = new ApplicationCredentials { ConsumerKey = "hardcoded-consumer", ConsumerSecret = key.ToXmlString(true) }; JiraOAuth1AProvider = new JIRAOAuth1aProvider(baseUrl); OAuth10AStateManager = new OAuth10aStateManager((k, v) => Session[k] = v, k => (string)Session[k]); }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AuthorizationRequest authorization = new AuthorizationRequest(); authorization.Reference = "REF1234"; authorization.RedirectURL = "http://www.lojamodelo.com.br/redirect"; authorization.NotificationURL = "http://www.lojamodelo.com.br/notification"; authorization.addPermission(PermissionType.CREATE_CHECKOUTS); authorization.addPermission(PermissionType.DIRECT_PAYMENT); authorization.addPermission(PermissionType.MANAGE_PAYMENT_PRE_APPROVALS); authorization.addPermission(PermissionType.RECEIVE_TRANSACTION_NOTIFICATIONS); authorization.addPermission(PermissionType.SEARCH_TRANSACTIONS); try { ApplicationCredentials credentials = PagSeguroConfiguration.GetApplicationCredentials(isSandbox); String result = authorization.Register(credentials); } catch (WebException exception) { } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
public UsingBot() { StartupChannels = new List <StartupChannel> { new StartupChannel() { ID = 1, UserID = "1", DisplayName = "a" } }; Players = new List <Player> { new Player() { ID = 1, TwitchUserID = "1", Name = "a" } }; PrimaryChannelName = Name.From("p"); CommandStatus = "s"; MockedContext = new Mock <IApplicationContext>(); MockedCredentialsManager = new Mock <ICredentialsManager>(); MockedContext.Setup(x => x.StartupChannels).Returns(() => StartupChannels.ToDbSet()); MockedContext.Setup(x => x.Players).Returns(() => Players.ToDbSet()); Username = Guid.NewGuid().ToString(); TwitchOAuth = Guid.NewGuid().ToString(); ChannelName = Guid.NewGuid().ToString(); ApplicationCredentials = new ApplicationCredentials() { ID = 1, InitialTwitchPrimaryChannelName = ChannelName, TwitchAPIClientID = Guid.NewGuid().ToString(), WolframAlphaAppID = Guid.NewGuid().ToString() }; MockedWriter = new(); JoinedChannels = new List <JoinedChannel>(); LoginCredentials = new(new(Username, TwitchOAuth, disableUsernameCheck : true), true, PrimaryChannelName); var credentials = LoginCredentials; MockedCredentialsManager.Setup(x => x.TryUpdateLoginCredentials(It.IsAny <LoginCredentials>(), out credentials)).Returns(true); MockedCommandRepository = new Mock <ICommandRepository>().SetupAllProperties(); MockedCommandRepository.Setup(x => x.GetStatus()).Returns(CommandStatus); MockedTwitchClientManager = new Mock <ITwitchClientManager>().SetupAllProperties(); MockedTwitchClientManager.Setup(x => x.TryInitializeTwitchClient(It.IsAny <IBot>(), It.IsAny <IClientOptions>(), It.IsAny <LoginCredentials>())).Returns(LoginCredentials); MockedTwitchClientManager.Setup(x => x.TryJoinInitialChannels(It.IsAny <IReadOnlyList <JoinedChannel> >())).Returns(true); MockedClient = new Mock <ITwitchClient>(); RegularClientOptions = new RegularClientOptions(); ModeratorClientOptions = new ModeratorClientOptions(); MockedTwitchClientManager .Setup(x => x.Client) .Returns(MockedClient.Object); MockedClient .Setup(x => x.Connect()) .Callback(() => { MockedClient .Setup(x => x.IsConnected) .Returns(true); }); MockedClient .Setup(x => x.JoinedChannels) .Returns((IReadOnlyList <JoinedChannel>)JoinedChannels); MockedClient .Setup(x => x.JoinChannel(It.IsAny <String>(), It.IsAny <Boolean>())) .Callback((String channel, Boolean overrideCheck) => { JoinedChannels.Add(new JoinedChannel(channel)); if (MockedTwitchClientManager.Object.PrimaryChannelName == null) { MockedTwitchClientManager.Object.PrimaryChannelName = channel; } }); MockedTwitchClientManager .Setup(x => x.EnsureJoinedToChannel(It.IsAny <String>())) .Callback((String channel) => { MockedClient.Object.JoinChannel(channel); MockedClient.Setup(x => x.IsConnected).Returns(true); }) .Returns(true); Sut = new( MockedWriter.Object, MockedCommandRepository.Object, ModeratorClientOptions, RegularClientOptions, MockedTwitchClientManager.Object); Sut.LoginCredentials = LoginCredentials; MockedTwitchClientManager.Invocations.Clear(); MockedCommandRepository.Invocations.Clear(); MockedClient.Invocations.Clear(); }
public FacebookClient(IHttpClientFactory clientFactory, IOptions <ApplicationCredentials> options) { this.facebookHttpClient = clientFactory.CreateClient(Facebook.Constants.Facebook.FacebookClientName); this.applicationCredentials = options.Value; }
internal Authentication(ApplicationCredentials applicationCredentials) { ApplicationCredentials = applicationCredentials; HttpClient = new HttpClient(); }