Hi,


I have build SwaggerUI(5.2.1) with Web API 2.0, while doing authentication 
I'm facing redirect URL issue from authorization URL.


*Error Processing Request The redirect_uri in the 
request: http://xxxx/swagger/ui/o2c-html 
<http://xxxx/swagger/ui/o2c-html> did not match a registered redirect URI.*

*below is my SwaggerConfig.cs*


Where to set Redirect Uri?


public class SwaggerConfig
{
    public static void Register()
    {
        var thisAssembly = typeof(SwaggerConfig).Assembly;

        GlobalConfiguration.Configuration
            .EnableSwagger(c =>
            {                    
                  c.SingleApiVersion("v1", "REST API");                

                  c.OAuth2("oauth2")
                    .Description("OAuth2 Implicit Grant")
                    .Flow("implicit")
                    .AuthorizationUrl(GetOAuth2Url())
                    .TokenUrl(GetTokenUriString())
                    .Scopes(scopes =>
                    {
                        
scopes.Add(ConfigurationManager.AppSettings["RelyingPartyRealm"], "Read access 
to protected resources");
                    });

                  c.IgnoreObsoleteActions();
                  c.IgnoreObsoleteProperties();
                  
c.OperationFilter<SwaggerExtensions.AssignOAuth2SecurityRequirement>();
                  c.ResolveConflictingActions(apiDescriptions => 
apiDescriptions.ToList().First());                    
                  c.IncludeXmlComments(GetXmlCommentsPath());
            })
            .EnableSwaggerUi(c =>
            {                                   
                  c.DisableValidator();                     
                  
c.EnableOAuth2Support(ConfigurationManager.AppSettings["OAuthClientName"], 
ConfigurationManager.AppSettings["RelyingPartyRealm"], 
ConfigurationManager.AppSettings["ApplicationName"]);
            });
    }

    private static string GetXmlCommentsPath()
    {
        return string.Format(@"{0}\bin\ApiGateway.Api.XML", 
AppDomain.CurrentDomain.BaseDirectory);
    }

    private static string GetOAuth2Url()
    {
        return ConfigurationManager.AppSettings["AuthorizationUri"];
    }

    private static string GetTokenUriString()
    {
        return ConfigurationManager.AppSettings["TokenUri"];
    }
}



-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to swagger-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to