User must be authenticated with Spring Security before authorization can be completed.

在整合SpringOAuth2.0时,启动后访问/oauth/authorize接口获取code时
显示User must be authenticated with Spring Security before authorization can be completed.异常,这个异常我在网上看了一些解决方案,都不符合我的问题。有一个是这样的
User must be authenticated with Spring Security before authorization can be completed.
没用!

还一种就是
User must be authenticated with Spring Security before authorization can be completed.
还一种
User must be authenticated with Spring Security before authorization can be completed.
也解决不了,启动调试模式,看了一下
User must be authenticated with Spring Security before authorization can be completed.
User must be authenticated with Spring Security before authorization can be completed.
问题锁定principal这个值为空,然后就搜索了一下,找到这篇文章,
OAuth2.0授权码/oauth/authorize接口调用unauthorized异常,但是这里也没说很详细,但是大致意思就是获取不到登录用户的信息,当然了,我这里压根就没登录,然后就结合了几篇文章,推断了一下,可能是版本高低问题,导致我现在的SpringOAuth2.0授权是必须登录吧!

然后把配置文件中的basic登录方式由关闭改为打开,然后就可以了
User must be authenticated with Spring Security before authorization can be completed.
User must be authenticated with Spring Security before authorization can be completed.
得到code
User must be authenticated with Spring Security before authorization can be completed.