授权代码是否必须授予资源访问权限?
Is Authorization code mandatory to grant resource access?
我正在开发 Spring 需要从第 3 方网络应用程序访问资源的引导网络应用程序。我试图了解 Oauth2 的工作原理。第 3 方 Web 应用程序使用 Oauth2 授予客户端资源访问权限。来自 3rd 方网络应用程序的文档说要发送一个 POST 和下面提到的格式的请求参数。
用户名=<###>&密码=<###>&client_id=<###>&client_secret=<###>&grant_type=密码&hcode=<###>
hcode 值根据文档是固定的。
我能够编写 java 代码成功获取我的访问令牌(感谢 Google 搜索!)。
以下是我的问题...
- 这里使用的是什么类型的赠款?
- 这是授权码授予吗?我在这里没有看到授权码。
PS:我是网络应用程序开发的新手。我指的是下面的 post 来理解 Oauth2。
[https://www.javainuse.com/spring/spring-boot-oauth-introduction]
String content = "-----";
BufferedReader reader = null;
HttpsURLConnection connection = null;
String returnValue = "";
URL url = new URL(CredentialDto.getTockenurl());
connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Authorization", "Basic " +
CredentialDto.getAuthentication());
connection.setRequestProperty("Content-Type", "application/x-www-form-
urlencoded");
connection.setRequestProperty("Accept", "application/json");
PrintStream os = new PrintStream(connection.getOutputStream());
os.print(content);
os.close();
reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String line = null;
StringWriter out = new StringWriter(connection.getContentLength() > 0 ?
connection.getContentLength() : 2048);
while((line = reader.readLine()) != null) {
out.append(line);
}
accessToken = out.toString();
Matcher matcher = PAT.matcher(retuenValue); if(matcher.matches() &&
matcher.groupCount() > 0) {
accessToken = matcher.group(1);
}
1 这里使用的是什么类型的赠款?
资源所有者密码凭证 (ROPC)。检查这个 RFC
2 这是授权码授予吗?我在这里没有看到授权码。
没有
我正在开发 Spring 需要从第 3 方网络应用程序访问资源的引导网络应用程序。我试图了解 Oauth2 的工作原理。第 3 方 Web 应用程序使用 Oauth2 授予客户端资源访问权限。来自 3rd 方网络应用程序的文档说要发送一个 POST 和下面提到的格式的请求参数。
用户名=<###>&密码=<###>&client_id=<###>&client_secret=<###>&grant_type=密码&hcode=<###>
hcode 值根据文档是固定的。 我能够编写 java 代码成功获取我的访问令牌(感谢 Google 搜索!)。 以下是我的问题...
- 这里使用的是什么类型的赠款?
- 这是授权码授予吗?我在这里没有看到授权码。
PS:我是网络应用程序开发的新手。我指的是下面的 post 来理解 Oauth2。 [https://www.javainuse.com/spring/spring-boot-oauth-introduction]
String content = "-----";
BufferedReader reader = null;
HttpsURLConnection connection = null;
String returnValue = "";
URL url = new URL(CredentialDto.getTockenurl());
connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Authorization", "Basic " +
CredentialDto.getAuthentication());
connection.setRequestProperty("Content-Type", "application/x-www-form-
urlencoded");
connection.setRequestProperty("Accept", "application/json");
PrintStream os = new PrintStream(connection.getOutputStream());
os.print(content);
os.close();
reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String line = null;
StringWriter out = new StringWriter(connection.getContentLength() > 0 ?
connection.getContentLength() : 2048);
while((line = reader.readLine()) != null) {
out.append(line);
}
accessToken = out.toString();
Matcher matcher = PAT.matcher(retuenValue); if(matcher.matches() &&
matcher.groupCount() > 0) {
accessToken = matcher.group(1);
}
1 这里使用的是什么类型的赠款?
资源所有者密码凭证 (ROPC)。检查这个 RFC
2 这是授权码授予吗?我在这里没有看到授权码。
没有