示例#1
0
        private static void GetToken(string authenticationArtifact, Dictionary <string, string> body)
        {
            var settings = EVEMon.Gateways.Properties.Settings.Default;
            var content  = new FormUrlEncodedContent(body);
            var result   = settings.LoginServerBaseUrl
                           .AppendPathSegment("token")
                           .WithBasicAuth(settings.ClientID, settings.ClientSecret)
                           .PostAsync(content)
                           .ReceiveString()
                           .Result;

            var obj  = JObject.Parse(result);
            var args = new SSOCompleteEventArgs
            {
                AccessToken  = obj.SelectToken("access_token").Value <string>(),
                Expires      = obj.SelectToken("expires_in").Value <int>(),
                RefreshToken = obj.SelectToken("refresh_token").Value <string>()
            };

            if (body["grant_type"] == "authorization_code")
            {
                args.AuthorizationToken = authenticationArtifact;
            }

            // Before we finish, we need to get details of the character we're dealing with:
            GetCharacterDetailsFromSSO(ref args);

            // An event to signal that the SSO process has finished.
            GlobalEvents.Complete(null, args);
        }
示例#2
0
 private static void SSOComplete(object sender, SSOCompleteEventArgs args)
 {
     Console.WriteLine("We have a response as follows:");
     Console.WriteLine($"Access token: {args.AccessToken}.");
     Console.WriteLine($"Auth token: {args.AuthorizationToken}.");
     Console.WriteLine($"Refresh token: {args.RefreshToken}.");
     Console.WriteLine($"Expires: {args.Expires}.");
 }
示例#3
0
        private static void GetCharacterDetailsFromSSO(ref SSOCompleteEventArgs args)
        {
            var Settings  = Properties.Settings.Default;
            var Character = Settings.LoginServerBaseUrl.AppendPathSegment("verify")
                            .WithOAuthBearerToken(args.AccessToken)
                            .GetAsync()
                            .ReceiveJson()
                            .Result;

            args.CharacterName      = Character.CharacterName;
            args.CharacterID        = (int)Character.CharacterID;
            args.CharacterOwnerHash = Character.CharacterOwnerHash;
        }
示例#4
0
 public bool SetCharacterTokens(SSOCompleteEventArgs args)
 {
     return(true);
 }