这里我使用ajax调用并获取访问令牌。如何在不使用ajax调用的情况下获取访问令牌?任何人都可以帮助我。 使用spring boot创建的授权服务器。
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
layout:decorator="maintemplate">
<head>
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"> </script>-->
<title>Spring Security Example </title>
</head>
<body>
<div layout:fragment="bodyContent">
<h1>Login</h1>
<label>Username</label><input type="text" id="username" name="username"/>
<label>Password</label><input type="password" id="password" name="password"/>
<div class="portlet-filters">
<div>
<button type="button" style="margin-top: 10px; " class="btn btn-sm btn-primary form-control" th:onclick="'search()'">Login</button>
</div>
</div>
</div>
<div layout:fragment="scripts">
<script type="text/javascript" th:inline="javascript">
function search() {
var username = $('#username').val();
var password = $('#password').val();
var encoded = btoa("foo:foosecret");
$.ajax({
type: "POST",
url: "/authservice/oauth/token",
data: {grant_type: 'password', username: username, password: password},
headers: {
"Authorization": "Basic " + encoded,
"Content-type": "application/x-www-form-urlencoded; charset=utf-8"
},
success: function () {
alert("Data Saved: ");
}
});
}
</script>
</div>
</body>
答案 0 :(得分:0)
以下内容......我改变了一些东西,所以它没有引用我的网址,但是我为我的auth服务器工作:
Not supported yet, I tried to get it into SP 20 but due to time constraints DEV can't get it into VS until SP 21, due out in September time...