public OidcTokenResponse CreateTokenResponse(StoredGrant grant)
        {
            var accessToken = CreateAccessToken(grant.Subject, _issuer + "/userinfo", grant.ClientId, grant.Scopes);
            var response = new OidcTokenResponse
            {
                AccessToken = accessToken.ToJwtString(),
                TokenType = "Bearer",
                ExpiresIn = 60 * 60
            };

            if (grant.GrantType == StoredGrantType.AuthorizationCode)
            {
                var idToken = CreateIdentityToken(grant.Subject, grant.ClientId);
                response.IdentityToken = idToken.ToJwtString();
            }

            return response;
        }
Example #2
0
        public OidcTokenResponse CreateTokenResponse(StoredGrant grant, int accessTokenLifetime)
        {
            var accessToken = CreateAccessToken(grant.Subject, _issuer + "/userinfo", grant.ClientId, grant.Scopes, accessTokenLifetime);
            var response    = new OidcTokenResponse
            {
                AccessToken = accessToken.ToJwtString(),
                TokenType   = "Bearer",
                ExpiresIn   = accessTokenLifetime * 60
            };

            if (grant.GrantType == StoredGrantType.AuthorizationCode)
            {
                var idToken = CreateIdentityToken(grant.Subject, grant.ClientId, 60);
                response.IdentityToken = idToken.ToJwtString();
            }

            return(response);
        }
 public static HttpResponseMessage CreateTokenResponse(this HttpRequestMessage request, OidcTokenResponse response)
 {
     Tracing.Information("Returning token response.");
     return request.CreateResponse<OidcTokenResponse>(HttpStatusCode.OK, response);
 }