示例#1
0
        public virtual Task GetProfileDataAsync(ProfileDataRequestContext context, CancellationToken cancellationToken)
        {
            BitJwtToken bitJwtToken = BitJwtToken.FromJson(context.Subject.Claims.GetClaimValue("primary_sid"));

            context.IssuedClaims = BuildClaimsFromBitJwtToken(bitJwtToken);

            return(base.GetProfileDataAsync(context));
        }
        public virtual BitJwtToken GetBitJwtToken()
        {
            if (!IsLoggedIn())
            {
                throw new InvalidOperationException("User is not logged in.");
            }

            Token token = GetCurrentToken() !;

            var handler = new JwtSecurityTokenHandler();

            var jwtToken = (JwtSecurityToken)handler.ReadToken(token.access_token);

            var primary_sid = jwtToken.Claims.First(c => c.Type == "primary_sid").Value;

            return(BitJwtToken.FromJson(primary_sid));
        }
        public virtual async Task <BitJwtToken> GetBitJwtTokenAsync(CancellationToken cancellationToken)
        {
            if (!await IsLoggedInAsync(cancellationToken).ConfigureAwait(false))
            {
                throw new InvalidOperationException("User is not logged in.");
            }

            Token token = (await GetCurrentTokenAsync(cancellationToken).ConfigureAwait(false)) !;

            var handler = new JwtSecurityTokenHandler();

            var jwtToken = (JwtSecurityToken)handler.ReadToken(token.access_token);

            var primary_sid = jwtToken.Claims.First(c => c.Type == "primary_sid").Value;

            return(BitJwtToken.FromJson(primary_sid));
        }