Beispiel #1
0
        public async static Task <Session> CreateOauthSession()
        {
            if (server != null)
            {
                server.Stop();

                while (server.isRunning)
                {
                    Console.WriteLine("IS RUNNING STILL");
                    await Task.Delay(100);
                }
            }
            GitHubClient g = new GitHubClient(Header);

            server = new CallBackServer("127.0.0.1", 4567, g);


            var request = new OauthLoginRequest(Session.clientId)
            {
                Scopes = { "user", "notifications", "repo" }
            };

            try {
                String oauthLoginUrl = g.Oauth.GetGitHubLoginUrl(request).ToString();
                System.Diagnostics.Process.Start(oauthLoginUrl);

                Session session = await server.Start();

                return(session);
            }
            catch (OperationCanceledException ex) {
                Console.WriteLine("Callbackserver cancelled");
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 启动本地的回调监听服务
 /// </summary>
 private static void CallBackListener()
 {
     CallBackServer.Inst(callBackUrl);
 }