简体   繁体   English

使用Rest模板Java获取Auth0管理令牌

[英]Get Auth0 Management token using rest template java

有什么方法可以使用rest模板获取auth0管理令牌令牌吗?

Left you comments as unclear precisely what you are asking. 留下的评论不清楚您要问的是什么。 But in summary, getting an Auth0 Management Token should be possible with any Java library that handles HTTP request / response. 但总而言之,任何处理HTTP请求/响应的Java库都应该可以获取Auth0管理令牌。

Quick example of how this might look with say HttpClient library: 使用HttpClient库的简短外观示例:

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/octet-stream");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"client_id\":\"{{CLIENT ID}}\",\n\t\"client_secret\":\"{{CLIENT SECRET}}\",\n\t\"audience\":\"https://{{TENANT}}.auth0.com/api/v2/\",\n\t\"grant_type\":\"client_credentials\"\n\t\n}");
Request request = new Request.Builder()
  .url("https://{{TENANT}}.auth0.com/oauth/token")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

Here is a screenshot of the resultant Token in jwt.io : 这是jwt.io中生成的Token的屏幕截图:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM