public static bool TryGetToken(string resourceName, out TokenCredential tokenCredential)
        {
            var vault = new PasswordVault();
            tokenCredential = null;

            try
            {
                var creds = vault.FindAllByResource(resourceName);
                if (creds != null)
                {
                    var credential = creds.First();
                    credential.RetrievePassword();
                    var json = JsonObject.Parse(credential.Password);

                    tokenCredential = new TokenCredential
                    {
                        AccessToken = json["access_token"].GetString(),
                        TokenType = json["token_type"].GetString(),
                    };

                    double expiresIn = json["expires_in"].GetNumber();
                    var dt = ((long)expiresIn).ToDateTimeFromEpoch();

                    tokenCredential.Expires = dt;

                    return true;
                }
            }
            catch
            { }

            return false;
        }
 private void RetrieveStoredToken()
 {
     TokenCredential credential;
     if (TokenVault.TryGetToken(_resourceName, out credential))
     {
         _credential = credential;
         _txtToken.Text = credential.AccessToken;
         _txtExpires.Text = credential.Expires.ToString();
     }
 }