コード例 #1
0
ファイル: Program.cs プロジェクト: stiez/evelib
        static void Main(string[] args)
        {
            Console.WriteLine("Simple tool for obtaining access and refresh tokens from the Eve Online SSO.");
            Console.WriteLine("No information is stored, some data is exchanged with the eve login servers.");
            Console.WriteLine("The sourcecode is available here: https://github.com/ezet/evelib");
            Console.WriteLine("You need to register an application at https://developers.eveonline.com, \nthe callback URL can be set to '/'.");
            Console.WriteLine("Your client ID and secret key will be provided by \nhttps://developers.eveonline.com after registering an application.\n");

            Console.WriteLine("For easier editing, rightclick the title bar for the console window, \nthen go to Properties -> Options -> enable QuickEdit mode.\n");
            Console.Write("Enter your client ID: ");
            string clientId = Console.ReadLine();

            Console.Write("Enter your secret key: ");
            string secret     = Console.ReadLine();
            string encodedKey = EveAuth.Encode(clientId, secret);
            string authLink   = Auth.CreateAuthLink(clientId, "/", CrestScope.PublicData);

            Console.WriteLine("Please log in using the following link: ");
            Console.WriteLine(authLink);
            Console.WriteLine("After logging in, copy the full URL from your browser.");
            Console.WriteLine("Enter the full URL: ");
            string url      = Console.ReadLine();
            string authCode = "";

            try {
                int start = url.IndexOf("?code=", System.StringComparison.Ordinal);
                int end   = url.IndexOf("&state", System.StringComparison.Ordinal);
                authCode = url.Substring(start + 6, end - start - 6);
            } catch (Exception) {
                Console.WriteLine("Unable to locate authentication code, please try again.");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("Authentication code found: " + authCode);
            Console.WriteLine("Authenticating...");
            AuthResponse response;

            try {
                response = Auth.AuthenticateAsync(encodedKey, authCode).Result;
            } catch (Exception) {
                Console.WriteLine("Authentication unsuccessfull, please try again.");
                return;
            }
            Console.WriteLine("Authentication successfull!");
            Console.WriteLine("\nAccess token:\n" + response.AccessToken);
            Console.WriteLine("\nRefresh token:\n" + response.RefreshToken);
            Console.WriteLine("\nEncoded key:\n" + encodedKey);
            Console.ReadKey();
        }
コード例 #2
0
ファイル: EveAuth_Tests.cs プロジェクト: cmptrgeekken/evelib
        public void GetAuthorizationLink()
        {
            var response = _eveAuth.CreateAuthLink(ClientId, "/", "default", EveAuth.AllCrestScopes);

            Trace.WriteLine(response);
        }
コード例 #3
0
 public string GetAuthLink()
 {
     return(_eveAuth.CreateAuthLink(_clientId, _redirectUri, "crest-login", _scope));
 }
コード例 #4
0
ファイル: EveAuth_Tests.cs プロジェクト: ams-tech/evelib
        public void GetAuthorizationLink()
        {
            string response = _eveAuth.CreateAuthLink(ClientId, "/", "default", CrestScope.PublicData);

            Trace.WriteLine(response);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: ams-tech/evelib
        static void Main(string[] args)
        {
            Console.WriteLine("Simple tool for obtaining access and refresh tokens from the Eve Online SSO.");
            Console.WriteLine("No information is stored, some data is exchanged with the eve login servers.");
            Console.WriteLine("The sourcecode is available here: https://github.com/ezet/evelib");
            Console.WriteLine("You need to register an application at https://developers.eveonline.com, \nthe callback URL can be set to '/'.");
            Console.WriteLine("Make sure you enable CREST and add the publicData scope for your application!\n");
            Console.WriteLine("Your client ID and secret key will be provided by \nhttps://developers.eveonline.com after registering an application.\n");

            Console.WriteLine("For easier editing, rightclick the title bar for the console window, \nthen go to Properties -> Options -> enable QuickEdit mode.\n");
            Console.Write("Please select SSO server: (1) Tranquility or (2) Singularity: ");
            var server = Console.ReadLine();

            if (server == "2")
            {
                Auth.Host = "sisilogin.testeveonline.com";
            }
            Console.WriteLine("Enter your client ID: ");
            //var clientId = Console.ReadLine();
            var clientId = "cefe601d9f5a444183f8c732676709fb";

            Console.WriteLine("Enter your secret key: ");
            //var secret = Console.ReadLine();
            var secret     = "Gwg3JNT8V0DLZwb7ZmRke9zJDYp1ePnUm9V5zvjY";
            var encodedKey = EveAuth.Encode(clientId, secret);

            Console.WriteLine("Please enter your request scopes as a space delimited string: ");
            //string scopes = Console.ReadLine();
            var scopes =
                "publicData characterFittingsRead characterFittingsWrite characterStatisticsRead characterContactsRead";
            var authLink = Auth.CreateAuthLink(clientId, "/", "default", scopes);

            System.Windows.Forms.Clipboard.SetText(authLink);
            Console.WriteLine("Please log in using the following link (already copied to your clipboard): ");
            Console.WriteLine(authLink);
            Console.WriteLine("After logging in, copy the full URL from your browser.");
            Console.WriteLine("Enter the full URL: ");
            string url      = Console.ReadLine();
            string authCode = "";

            try {
                int start = url.IndexOf("?code=", System.StringComparison.Ordinal);
                int end   = url.IndexOf("&state", System.StringComparison.Ordinal);
                authCode = url.Substring(start + 6, end - start - 6);
            }
            catch (Exception) {
                Console.WriteLine("Unable to locate authentication code, please try again.");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("Authentication code found: " + authCode);
            Console.WriteLine("Authenticating...");
            AuthResponse response;

            try {
                response = Auth.AuthenticateAsync(encodedKey, authCode).Result;
            }
            catch (Exception) {
                Console.WriteLine("Authentication unsuccessfull, please try again.");
                return;
            }
            Console.WriteLine("Authentication successfull!");
            Console.WriteLine("\nAccess token:\n" + response.AccessToken);
            Console.WriteLine("\nRefresh token:\n" + response.RefreshToken);
            Console.WriteLine("\nEncoded key:\n" + encodedKey);
            Console.ReadLine();
        }