Exemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EveCrest" /> class, in Authenticated mode.
 /// </summary>
 /// <param name="accessToken">The access token.</param>
 public DynamicCrest(string accessToken)
     : this()
 {
     AccessToken = accessToken;
     Mode        = CrestMode.Authenticated;
     EveAuth     = new EveAuth();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Refreshes the access token. This requires a valid RefreshToken and EncodedKey to have been set.
        /// The EveCrest instance is updated with the new access token.
        /// </summary>
        /// <returns>Task&lt;AuthResponse&gt;.</returns>
        public AuthResponse RefreshAccessToken()
        {
            var response = EveAuth.RefreshAsync(EncodedKey, RefreshToken).Result;

            AccessToken  = response.AccessToken;
            RefreshToken = response.RefreshToken;
            return(response);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Refreshes the access token. This requires a valid RefreshToken and EncodedKey to have been set.
        /// The EveCrest instance is updated with the new access token.
        /// </summary>
        /// <returns>Task&lt;AuthResponse&gt;.</returns>
        public async Task <AuthResponse> RefreshAccessTokenAsync()
        {
            var response = await EveAuth.RefreshAsync(EncodedKey, RefreshToken).ConfigureAwait(false);

            AccessToken  = response.AccessToken;
            RefreshToken = response.RefreshToken;
            return(response);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EveCrest" /> class, in Authenticated mode.
 /// </summary>
 /// <param name="accessToken">The access token.</param>
 public EveCrest(string accessToken)
     : this()
 {
     AccessToken = accessToken;
     Host        = DefaultHost;
     Mode        = CrestMode.Authenticated;
     EveAuth     = new EveAuth();
     EnableAutomaticTokenRefresh = false;
 }
Exemplo n.º 5
0
        private string GetEncodedKey()
        {
            if (string.IsNullOrEmpty(Authentication.Default.ClientId) ||
                string.IsNullOrEmpty(Authentication.Default.ClientSecret))
            {
                return(null);
            }

            return(EveAuth.Encode(Authentication.Default.ClientId, Authentication.Default.ClientSecret));
        }
Exemplo n.º 6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EveCrest" /> class, in Authenticated mode.
 /// </summary>
 /// <param name="refreshToken">The refresh token.</param>
 /// <param name="encodedKey">The encoded key.</param>
 public DynamicCrest(string refreshToken, string encodedKey)
     : this()
 {
     RefreshToken = refreshToken;
     AccessToken  = "";
     EncodedKey   = encodedKey;
     Mode         = CrestMode.Authenticated;
     EveAuth      = new EveAuth();
     EnableAutomaticTokenRefresh = true;
 }
Exemplo n.º 7
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EveCrest" /> class, in Authenticated mode.
 /// </summary>
 /// <param name="refreshToken">The refresh token.</param>
 /// <param name="encodedKey">The encoded key.</param>
 public EveCrest(string refreshToken, string encodedKey)
     : this()
 {
     RefreshToken = refreshToken;
     EncodedKey   = encodedKey;
     Host         = DefaultAuthHost;
     Mode         = CrestMode.Authenticated;
     EveAuth      = new EveAuth();
     EnableAutomaticTokenRefresh = true;
 }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
 public EveService(string refreshToken)
 {
     _eveAuth  = new EveAuth();
     _eveCrest = new EveCrest(refreshToken, GenerateEncryptedKey());
 }
Exemplo n.º 10
0
 public EveService(EveAuth eveAuth, EveCrest eveCrest)
 {
     _eveAuth  = eveAuth;
     _eveCrest = eveCrest;
 }
Exemplo n.º 11
0
        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();
        }