예제 #1
0
    public IOAuthClientResponse CreateAuthorizationCodeWithPkceRedirect(IEnumerable <string> scopes = null, string state = null)
    {
        var codeVerifier = PkceUtils.GenerateCodeVerifier();

        var queryStringParams = new Dictionary <string, string>
        {
            { Common.ResponseType, ResponseTypes.Code },
            { Common.ClientId, _configuration.ClientId },
            { Common.RedirectUri, _configuration.RedirectUri },
            { Common.State, state ?? StateUtils.Generate() },
            { Common.CodeChallenge, PkceUtils.GenerateCodeChallenge(codeVerifier) },
            { Common.CodeChallengeMethod, CodeChallengeMethodTypes.S256 }
        }.AddScopes(scopes);

        var redirectUri = QueryHelpers.AddQueryString(_configuration.AuthorizeEndpoint, queryStringParams);

        var response = new OAuthRedirect
        {
            Uri          = redirectUri,
            State        = state,
            CodeVerifier = codeVerifier
        };

        return(response);
    }
예제 #2
0
    public IOAuthClientResponse CreateAuthorizationCodeRedirect(IEnumerable <string> scopes = null, string state = null)
    {
        var queryStringParams = new Dictionary <string, string>
        {
            { Common.ResponseType, ResponseTypes.Code },
            { Common.ClientId, _configuration.ClientId },
            { Common.RedirectUri, _configuration.RedirectUri },
            { Common.State, state ?? StateUtils.Generate() }
        }.AddScopes(scopes);

        var redirectUri = QueryHelpers.AddQueryString(_configuration.AuthorizeEndpoint, queryStringParams);

        var response = new OAuthRedirect
        {
            Uri   = redirectUri,
            State = state
        };

        return(response);
    }