| | |
| | | |
| | | /** |
| | | * 免密登录 |
| | | * @param account 账号 |
| | | * @param username 账号 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean passwordFreeLogin(String account) { |
| | | public boolean passwordFreeLogin(String username) { |
| | | // 免密登录接口地址 |
| | | String loginUrl = "http://localhost:"+this.getGatewayPort()+"/ubcs-auth/oauth/passwordFreeLogin?username=admin&grant_type=captcha&scope=all&type=account"; |
| | | String loginUrl = "http://localhost:"+this.getGatewayPort()+"/ubcs-auth/oauth/password-free-login"; |
| | | |
| | | // 设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | headers.set("Authorization", "Basic c3dvcmQ6c3dvcmRfc2VjcmV0"); |
| | | headers.set("Tenant-Id", "000000"); |
| | | |
| | | //设置请求体参数 |
| | | MultiValueMap<String,String> bodyParams = new LinkedMultiValueMap<String,String>(); |
| | | bodyParams.add("account",account); |
| | | MultiValueMap<String,String> parameters = new LinkedMultiValueMap<String,String>(); |
| | | parameters.add("username",username); |
| | | parameters.add("grant_type", "captcha"); |
| | | parameters.add("scope", "all"); |
| | | parameters.add("type", "account"); |
| | | |
| | | // 发送POST请求 |
| | | String responseBody = HttpUtils.post(loginUrl, bodyParams); |
| | | String responseBody = HttpUtils.post(loginUrl, parameters,headers); |
| | | System.out.println(responseBody); |
| | | //拿到响应体将token存入到redis中,以account作为存储的key |
| | | |