<div>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" th:href="@{/}">Spring Security OAuth</a>
    </div>
    
  </div><!-- /.container-fluid -->
</nav>


<oauth
  site="http://localhost:8081/spring-security-oauth-server"
  client-id="clientId"
  redirect-uri="http://localhost:8081/spring-security-oauth-ui-implicit/index"
  scope="read"
  template="oauthTemp">
</oauth>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-resource.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ngStorage/0.3.9/ngStorage.min.js"></script>


<script th:src="@{/resources/oauth-ng.js}"></script>
<script>
/*<![CDATA[*/
var app = angular.module('myApp', ["ngResource","ngRoute","oauth"]);
app.config(function($locationProvider) {
  $locationProvider.html5Mode({
	  enabled: true,
	  requireBase: false
	}).hashPrefix('!');
});



app.controller('mainCtrl', function($scope,$resource,$http) {
	
	$scope.$on('oauth:login', function(event, token) {
		$http.defaults.headers.common.Authorization= 'Bearer ' + token.access_token;
		console.log('Authorized third party app with token', token.access_token);
	});

	$scope.foo = {id:0 , name:"sample foo"};
    $scope.foos = $resource("http://localhost:8081/spring-security-oauth-resource/foos/:fooId",{fooId:'@id'});
    
	$scope.getFoo = function(){
		$scope.foo = $scope.foos.get({fooId:$scope.foo.id});
	}
    
});
/*]]>*/
</script>
</div>