curl - How to send the client id and secret id of OAuth2 using AngularJs? -
i have rest api oauth2 developed using spring boot resource server , authorization server. fetch token using curl, postman rest client , request granted service using token provided oauth. now, need know how pass oauth2 client_id, secret_id using angularjs , know what's usage of -vu in following curl request,
curl -x post -vu clientapp:123456 http://localhost:8080/oauth/token -h "accept: application/json" -d "password=spring&username=roy&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp". please me know , provide me samples work on angularjs ?
tia..,
here's example jhipster: https://github.com/jhipster/jhipster-sample-app-oauth2/blob/master/src/main/webapp/scripts/components/auth/provider/auth.oauth2.service.js
note: i'd use blank client secret (both in angularjs , spring) since secret isn't secret in js anyway. see https://stackoverflow.com/a/32062458/1098564 , below:
return { login: function(credentials) { var data = "username=" + credentials.username + "&password=" + credentials.password + "&grant_type=password&scope=read%20write&"; return $http.post('oauth/token', data, { headers: { "content-type": "application/x-www-form-urlencoded", "accept": "application/json", "authorization": "basic " + base64.encode("myapp" + ':' + "") } }).success(function (response) { var expiredat = new date(); expiredat.setseconds(expiredat.getseconds() + response.expires_in); response.expires_at = expiredat.gettime(); localstorageservice.set('token', response); return response; }); },
as curl, -v option "verbose" , -u option pass user credentials (options explained here: http://curl.haxx.se/docs/manpage.html)
Comments
Post a Comment