@Authorization is not working - com.sun.jersey.api.NotFoundException

42 views
Skip to first unread message

Lata

unread,
Oct 8, 2015, 5:55:33 PM10/8/15
to Swagger
Hello,

I am using swagger 2.0, with Jersey 1.17.1 and tomcat 1.7.64.

I followed the java-jersey-sample-app, and added Bootstrap java class.
and added authorization annotation as:

@Api(value="client", authorizations = {
 @Authorization(value = "nbo_auth",
 scopes = {
   @AuthorizationScope(scope = "delete:client", description = "delete client")
})
}

and my swagger base api from web.xml is /SO/attnsapi.
from Bootstrap class:

ServletContext context = config.getServletContext();
    Swagger swagger = new Swagger().info(info);
    swagger.externalDocs(new ExternalDocs("Find out more about Swagger", "http://swagger.io"));
    swagger.securityDefinition("api_key", new ApiKeyAuthDefinition("api_key", In.HEADER));
    swagger.securityDefinition("nbo_auth", 
      new OAuth2Definition()
        .scope("delete:client", "delete client")
        /*.scope("write:pets", "modify pets in your account")*/);
    swagger.tag(new Tag()
      .name("client")
      .description("Client Management Operations")
      .externalDocs(new ExternalDocs("Find out more", "http://swagger.io")));
   
    context.setAttribute("swagger", swagger);

I also have jersey-servlet and jersey-server jars in the project build path.

but after calling delete api, I am getting this error:

<Severity>ERROR</Severity>
<Field/>
<Source>com.sun.jersey.api.NotFoundException</Source>
<Code>404</Code>
</ErrorType>


what I am missing here?

Thanks,

Ron Ratovsky

unread,
Oct 8, 2015, 6:16:07 PM10/8/15
to Swagger
Hi Lata,

Not sure when you actually get that error. How do you call the delete API? is http://localhost:8080/SO/attnsapi/oauth/dialog accessible when you run you application?

--
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-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------
Reply all
Reply to author
Forward
0 new messages