Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用1.5的版本可以拿到code 但是会返回401 #1

Open
SERE026 opened this issue Jul 19, 2018 · 0 comments
Open

使用1.5的版本可以拿到code 但是会返回401 #1

SERE026 opened this issue Jul 19, 2018 · 0 comments

Comments

@SERE026
Copy link

SERE026 commented Jul 19, 2018

  1. 使用1.5.x-RELEASE 的版本访问
    http://localhost:9090/oauth/authorize?response_type=code&client_id=client_3&redirect_uri=http://localhost:9090/redirect&scope=select
    重定向到http://localhost:9090/redirect?code=x88wib
    且页面返回如下信息
Full authentication is required to access this resource unauthorized
  1. 通过code 访问
    localhost:9090/oauth/authorize?client_id=client_3&response_type=code&scope=select&redirect_uri=http://localhost:9090/client/redirect&code=x88wib
    采用POST请求
    返回
    {
    "timestamp": 1531993410032,
    "status": 401,
    "error": "Unauthorized",
    "message": "Full authentication is required to access this resource",
    "path": "/oauth/authorize"
    }

  2. 代码是最简单的代码,按照博客操作的
    还请做着给予解答疑惑

代码如下:
@configuration
public class OAuth2Config {
@configuration
@EnableAuthorizationServer//是的,没做,就这么一个注解
public class AuthorizationServerConfig {
}

@Configuration
@EnableResourceServer//咦,没错还是一个注解
public class ResourceServerConfig {
}

}

@component
public class MyUserDetailsService implements UserDetailsService {
@OverRide
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return new User(username, "123456", AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
}
}

@RestController
@slf4j
public class AuthDemoEndpoint {

@RequestMapping("/redirect")
public String redirect(String code){
    log.info("oauth 2 code is :{}",code);
    return code;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant