文档
测试

获取access_token

POST
http://quyan4pl-gateway-dev.c8dfd77cdee5247d388409f67eae91522.cn-shanghai.alicontainer.com/auth/oauth/token

接口描述

client-id、client-secret、username、password 需要找趋研同事获取

请求头

参数名
类型
描述
必填
Content-Type
application/x-www-form-urlencoded
必填
Authorization
Basic Y2xpZW5...
必填

请求参数

参数名
类型
描述
必填
grant_type
password
必填
username
必填
password
必填
scope
all
必填

说明 / 示例

**请求示例** **java请求示例** ```javascript public String __getToken() { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", String.format("Basic %s", new String(Base64.encode(String.format("%s:%s", <your clientid>, <your client secret>).getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8))); MultiValueMap<String, String> form = new LinkedMultiValueMap<>(); form.set("grant_type", "password"); form.set("username", ""); form.set("password", ""); HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(form, headers); ResponseEntity<AccessTokenBO> response = getRestTemplate().exchange("http://xxxxx/auth/oauth/token", HttpMethod.POST, request, AccessTokenBO.class); return Optional.of(response).map(ResponseEntity::getBody).map(AccessTokenBO::getAccess_token).orElse(null); } ``` **response** ```javascript { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..", "token_type": "bearer", "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..", "scope": "all", "jti": "9f84771f-781a-..." } ```