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

关于第三方授权登录token生成问题 #585

Closed
janyyy opened this issue Jan 29, 2021 · 1 comment
Closed

关于第三方授权登录token生成问题 #585

janyyy opened this issue Jan 29, 2021 · 1 comment

Comments

@janyyy
Copy link

janyyy commented Jan 29, 2021

我模仿PC 登录生成token,但是第三方授权登录的时候。我只能从数据库拿密码。密码并不可逆,到这一步的时候就会提示用户名和密码不正确。
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword()); Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);

完整代码截图如下,能否给我点改造提示。有点迷。希望此贴有回复
image

@shaokuuipo
Copy link

shaokuuipo commented Feb 1, 2021

这个我改造好了。看代码
UserDetails userDetails = userDetailsService.loadUserByUsername(userInfo.getUsername());

Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());

SecurityContextHolder.getContext().setAuthentication(authentication);

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

3 participants