on 2023 Dec 04 2:38 PM
Following a tutorial, in my cap java project I try to configure the authorization using mock data.
Below the data modified.
service.cds
using { sap.capire.bookstore as db } from '../db/schema';<br>// Define Books Service<br>service BooksService {<br> entity Books as projection on db.Books { *, category as genre } excluding { category, createdBy, createdAt, modifiedBy, modifiedAt };<br> entity Authors as projection on db.Authors;<br>}<br>// Define Orders Service<br>service OrdersService {<br> entity Orders as projection on db.Orders;<br> entity OrderItems as projection on db.OrderItems;<br>}<br>// Reuse Admin Service<br>using { AdminService } from '@sap/capire-products';<br>extend service AdminService with {<br> entity Authors as projection on db.Authors;<br>}<br>annotate AdminService @(requires: 'Administrators');<br>annotate BooksService @(requires: 'Administrators');
application.yml
---<br>spring:<br> config.activate.on-profile: default<br>cds:<br> datasource:<br> auto-config.enabled: false<br> security:<br> mock:<br> users:<br> - name: jon<br> password: pass_jon<br> roles:<br> - Administrators<br> additional:<br> firstName: jon<br> lastName: jon<br> email: jon.jr@mail.com
http requestes
### get Authors<br>GET http://localhost:8080/odata/v4/BooksService/Authors<br>Accept: application/json<br>Authorization: Basic jon:pass_jon<br>### Read Products<br>GET http://localhost:8080/odata/v4/AdminService/Products<br>Accept: application/json<br>Authorization: Basic jon:pass_jon
Why the endpoint that need Adminsitrator role return me 401?
thanks
Request clarification before answering.
In your configuration you set "jon_davide" as password, but in your requests you use "pass_jon" as password. You need to make sure that both are the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
9 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.