Skip to Content
0
Former Member
May 17, 2018 at 12:03 AM

Access Denied while creating cart using webservices

958 Views

HI,

I am trying to create anonymous user cart using the webservices module. I get the following error.

{ "errors": [ { "message": "Access is denied", "type": "AccessDeniedError" } ] }

localhost:9001/customwebservices/v2/insurance/users/anonymous/carts/ - POST create cart

INFO [hybrisHTTP28] [RestHandlerExceptionResolver] Translating exception [org.springframework.security.access.AccessDeniedException]: Access is denied

I had created the oauth token

https://localhost:9002/authorizationserver/oauth/token?client_id=customuser&client_secret=secret&grant_type=client_credentials

token is generated and I use the same token to create cart for anonymous user.

I havae also added ROLE_TRUSTED_CLIENT to my controller.

 @RequestMapping(method = RequestMethod.POST)
 @ResponseStatus(HttpStatus.CREATED)
 @Secured(
 { "ROLE_CLIENT", "ROLE_TRUSTED_CLIENT" })
 @ResponseBody
 @ApiOperation(value = "Creates or restore a cart for a user.", notes = "Creates a new cart or restores an anonymous cs a user's cart (if an old Cart Id is given in the request).")
 @ApiBaseSiteIdAndUserIdParam
 public CartWsDTO createCart(@ApiParam(value = "Anonymous cart GUID.") @RequestParam(required = false) final String oldCartId,
         @ApiParam(value = "User's cart GUID to merge anonymous cart to.") @RequestParam(required = false) final String toMergeCartGuid,
         @ApiParam(value = "Response configuration (list of fields, which should be returned in response)", allowableValues = "BASIC, DEFAULT, FULL") @RequestParam(required = false, defaultValue = DEFAULT_FIELD_SET) final String fields)
 {

Please tell me what am I doing wrong?