问题
I used JHipster to create a micro-service architecture.
I'm using JHipster Registry and JHipster UAA (OAuth2) as authentication solution.
Now I'm looking for a way to authenticate and make some API calls from a mobile application that would be developed outside of JHipster.
I tried to call UAA service from outside by calling /oauth/token ressource but it doesn't work.
Any advices?
回答1:
In a microservice architecture, you want to make requests to microservices through the gateway so it can load-balance to your microservices (including the UAA). Use the login route through the gateway (/auth/login
), like the Angular and React clients do in auth-jwt.service.ts:
login(credentials): Observable<any> {
const data = {
username: credentials.username,
password: credentials.password,
rememberMe: credentials.rememberMe
};
return this.http.post(SERVER_API_URL + 'auth/login', data, {});
}
Note that you will also need to handle authentication via cookies, and make sure you sent the XSRF-TOKEN with each request.
来源:https://stackoverflow.com/questions/52264350/authentication-to-jhipster-uaa-from-non-jhipster-application