0

I have developed Spring-Rest APIs using Spring-Boot-1.3.1. Then I have provided Spring-OAuth2 Security for those APIs. This resides as asingle project in Apache Tomcat. APIS I developed:

GET -> /api/articles
GET -> /api/articles/1
POST -> /api/articles

Spring-Oauth2 provides below by default API:

POST -> /oauth/token
POST -> /oauth/authorize

and some more outh api.

Now I am developing AngularJS UI, which will reside in diferent server- Apache2-Http Server.

I need to know how do I integrate angularJS Login page with Spring-REST secured by Spring-OAuth2?

2 Answers2

0

You can you the following library to manage the tokens angular-oauth2

Steps:

  1. send login credentials to /oauth/token
  2. catch the response, extract the token and add it to the $http default headers so the token will be send with every request
Alexander
  • 3,019
  • 1
  • 20
  • 24
0

Use the code:

var data = "username=" + user.email + "&password=" + encodeURIComponent(user.password) + "&grant_type=password&scope=read%20write&" +
                    "client_secret=secret&client_id=frontend";



            $http.post(portalResources.login, data, {
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded",
                    "Accept": "application/json",
                    "Authorization": "Basic " + $base64.encode("frontend" + ':' + "secret")
                }
            });
Nataniel Paiva
  • 485
  • 4
  • 9