java OAuth2同意页未显示作用域

a0zr77ik  于 2023-03-06  发布在  Java
关注(0)|答案(1)|浏览(153)

我正在阅读《Spring在行动6和认证服务器不能正常工作》这本书。我试过自定义服务器或从网上复制一个,但没有帮助
链接:http://本地主机:9000/oauth2/授权?响应类型=代码&客户端ID= taco管理员客户端&重定向URI=http:127.0.0.1:9090/login/oauth2/code/taco-admin-client&-scope=writeIngredients+deleteIngredients
That's how it looks like
我的豆子:

@Bean
  public RegisteredClientRepository registeredClientRepository(
          PasswordEncoder passwordEncoder) {
    RegisteredClient registeredClient =
      RegisteredClient.withId(UUID.randomUUID().toString())
        .clientId("taco-admin-client")
        .clientSecret(passwordEncoder.encode("secret"))
        .clientAuthenticationMethod(
                ClientAuthenticationMethod.CLIENT_SECRET_BASIC)
        .authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
        .authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
        .redirectUri(
            "http://127.0.0.1:9090/login/oauth2/code/taco-admin-client")
        .scope("writeIngredients")
        .scope("deleteIngredients")
        .scope(OidcScopes.OPENID)
        .clientSettings(
            clientSettings -> clientSettings.requireUserConsent(true))
        .build();
    return new InMemoryRegisteredClientRepository(registeredClient);
  }

That's how it should be

c3frrgcw

c3frrgcw1#

我遇到了同样的问题,在我的例子中发生的是网址是错误的,它在“scope=writeIngredients+deleteIngredients”后面有一个额外的破折号,所以它没有显示范围。正确的网址应该是:http://localhost:9000/oauth2/authorize?response_type=code&client_id=taco-admin-client&redirect_uri=http://127.0.0.1:9090/login/oauth2/code/taco-admin-client&scope=writeIngredients+deleteIngredients

相关问题