I want use oauth2 in my ionic app. but i get error:
Failed to load resource: the server responded with a status of 401 ()
Error: Http failure response for http://localhost:8080/oauth/token: 401 OK
Response:
{"timestamp":1502983544253,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/oauth/token"}
Angular function:
login(username, password) : Observable<any> {
let params: HttpParams = new HttpParams();
params.set('username', username);
params.set('password', password);
params.set('client_id', this.clientId);
params.set('client_secret', this.clientSecret);
params.set('grant_type', 'password');
let headers = new HttpHeaders();
headers.set('Content-Type', 'application/x-www-form-urlencoded');
return this.http.post(this.EndPointUrl, {
params:params
}, { headers:headers}).map(this.handleData).
catch(this.handleError); }
I can get token using, PostMan and curl, CORS in my server is enabled for this endpoint so i think the auth server works properly.
Does anyone know what I’m doing wrong?