Esempio n. 1
0
        protected async Task SetResponse(HandlerContext handlerContext, JwsPayload jwsPayload, CancellationToken cancellationToken)
        {
            var authorizationCode = string.Empty;

            if (!handlerContext.Response.TryGet(AuthorizationResponseParameters.Code, out authorizationCode))
            {
                authorizationCode = handlerContext.Request.RequestData.GetAuthorizationCode();
            }

            var accessToken = await _jwtBuilder.BuildAccessToken(handlerContext.Client, jwsPayload, cancellationToken);

            await _grantedTokenHelper.AddAccessToken(accessToken, handlerContext.Client.ClientId, authorizationCode, cancellationToken);

            handlerContext.Response.Add(TokenResponseParameters.AccessToken, accessToken);
        }
Esempio n. 2
0
        public async virtual Task Build(IEnumerable <string> scopes, HandlerContext handlerContext, JObject claims = null)
        {
            var jwsPayload = _grantedTokenHelper.BuildAccessToken(new[]
            {
                handlerContext.Client.ClientId
            }, scopes, handlerContext.Request.IssuerName, handlerContext.Client.TokenExpirationTimeInSeconds);

            if (claims != null)
            {
                foreach (var cl in claims)
                {
                    jwsPayload.Add(cl.Key, cl.Value);
                }
            }

            var accessToken = await _jwtBuilder.BuildAccessToken(handlerContext.Client, jwsPayload);

            handlerContext.Response.Add(TokenResponseParameters.AccessToken, accessToken);
        }