Skip to content

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

Closed

Description

@janyyy

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

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

Activity

  1. shaokuuipo commented on Feb 1, 2021

    @shaokuuipo

    这个我改造好了。看代码
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions