/// <summary> /// The unauthenticated. /// </summary> private void Unauthenticated() { this.Receive <Authenticate>( auth => { // need a client to test our credentials with var client = GithubClientFactory.GetUnauthenticatedClient(); GithubClientFactory.OAuthToken = auth.OAuthToken; client.Credentials = new Credentials(auth.OAuthToken); this.BecomeAuthenticating(); client.User.Current().ContinueWith <object>( tr => { if (tr.IsFaulted) { return(new AuthenticationFailed()); } if (tr.IsCanceled) { return(new AuthenticationCancelled()); } return(new AuthenticationSuccess()); }).PipeTo(this.Self); }); }
private void Unauthenticated() { _statusUpdate(Name, "Enter Oauth ID (ie github key)"); Receive <Input>(input => { _service = Sender; Self.Tell(new Authenticate(input.Text)); }); Receive <Authenticate>(auth => { //need a client to test our credentials with var client = GithubClientFactory.GetUnauthenticatedClient(); GithubClientFactory.OAuthToken = auth.OAuthToken; client.Credentials = new Credentials(auth.OAuthToken); BecomeAuthenticating(); client.User.Current().ContinueWith <object>(tr => { if (tr.IsFaulted) { return(new AuthenticationFailed()); } if (tr.IsCanceled) { return(new AuthenticationCancelled()); } return(new AuthenticationSuccess()); }).PipeTo(Self); }); }
private void Unauthenticated() { Receive <Authenticate>(auth => { BecomeAuthenticating(auth); if (string.IsNullOrWhiteSpace(auth.OAuthToken)) { Self.Tell(new AuthenticationFailed()); return; } //need a client to test our credentials with GithubClientFactory .GetClient(auth.OAuthToken) .User .Current() .ContinueWith <object>(tr => { if (tr.IsFaulted) { return(new AuthenticationFailed()); } if (tr.IsCanceled) { return(new AuthenticationCancelled()); } return(new AuthenticationSuccess(auth.OAuthToken)); }) .PipeTo(Self); }); }
public static void InitializeContainer() { container = new Container(c => { c.For <IConnection>().Use <DiscordConnection>(); c.For <IConfiguration>().Use <ConfigManager>(); c.For <ICommandHandler>().Use <DiscordCommandHandler>(); c.For <ILogger>().Use <ConsoleLogger>(); c.For <IGitUserVerification>().Use <GitUserVerification>(); c.For <IGitweekStats>().Use <GitweekStats>(); c.ForSingletonOf <IJsonStorage>().UseIfNone <JsonStorage>(); c.ForSingletonOf <ILanguage>().UseIfNone <JsonLanguage>(); c.ForSingletonOf <WelcomeMessageService>().UseIfNone <WelcomeMessageService>(); c.ForSingletonOf <DiscordSocketClient>().UseIfNone(DiscordSocketClientFactory.GetDefault()); c.ForSingletonOf <GitHubClient>().UseIfNone(GithubClientFactory.GetDefault()); c.ForSingletonOf <HelperRoleHandler>(); }); }
public LauncherFormViewModel() { /* INITIALIZE ACTORS */ var props = Props.Create(() => new MainFormActor(this)); m_mainFormActor = App.GithubSystem.ActorOf(props, ActorPaths.MainFormActor.Name); props = Props.Create(() => new GithubCommanderActor()); App.GithubSystem.ActorOf(props, ActorPaths.GithubCommanderActor.Name); props = Props.Create(() => new GithubValidatorActor(GithubClientFactory.GetClient())); App.GithubSystem.ActorOf(props, ActorPaths.GithubValidatorActor.Name); LaunchSearch = ReactiveCommand.Create(null); LaunchSearch.Subscribe(x => DoLaunchSearch()); // to be able to launch a window from the actor system m_LaunchWindow = new Subject <MainFormActor.LaunchRepoResultsWindow>(); m_LaunchWindow.ObserveOnDispatcher().Subscribe(x => DoLaunchWindow(x)); }
private void Unauthenticated() { Receive <Authenticate>(auth => { //need a client to test our credentials with var client = GithubClientFactory.GetUnauthenticatedClient(); GithubClientFactory.OAuthToken = auth.OAuthToken; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; client.Credentials = new Credentials(auth.OAuthToken); BecomeAuthenticating(); client.User.Current().ContinueWith <object>(tr => { if (tr.IsFaulted) { return(new AuthenticationFailed()); } if (tr.IsCanceled) { return(new AuthenticationCancelled()); } return(new AuthenticationSuccess()); }).PipeTo(Self); }); }
private void Initializing() { Receive <ValidateRepo>(repo => ((IWithUnboundedStash)this).Stash.Stash()); Receive <AuthenticationSuccess>(auth => { App.UIActors .ActorSelection(ActorPaths.DispatcherCoordinator) .Tell(PageNavigate.Create <Views.LauncherForm, ViewModels.LauncherForm>( "Who Starred This Repo?", true)); var githubClientFactor = GithubClientFactory.GetClientFactory(auth.Token); repoValidatorActor = App.GithubActors.ActorOf( Props.Create <GetHubRepoValidatorActor>(githubClientFactor), ActorNames.RepoValidator); githubCommanderActor = App.GithubActors.ActorOf( Props.Create <GithubCommanderActor>(githubClientFactor), ActorNames.GithubCommander); BecomeReady(); }); }
public GithubService(GithubClientFactory githubClientFactory, GithubConfiguration configuration) { _githubClientFactory = githubClientFactory; _configuration = configuration; }