8

私はSpring OAuth認証サーバを持っており、複数のクライアント(ID)にサポートを追加したいと思います。私が最初にクライアントとアクセストークンを取得することができます複数のクライアントをSpring OAuth2認証サーバに追加する

clients 
      .inMemory().withClient(client).secret(clientSecret) 
      .resourceIds(resourceId) 
      .authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code") 
      .authorities("ROLE_USER") 
      .scopes("read", "write") 
      .autoApprove(true) 
      .and() 
      .inMemory().withClient("acme").secret("acmesecret") 
      .resourceIds(resourceId) 
      .authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code") 
      .authorities("ROLE_USER_ACME") 
      .scopes("read", "write") 
      .autoApprove(true); 

が、2番目のクライアントとアクセストークンを取得しようとしたとき、私はこのエラーを取得:私はこのようなクライアントを構成し

{ 
    "timestamp": 1456822249638, 
    "status": 401, 
    "error": "Unauthorized", 
    "message": "Bad credentials", 
    "path": "/oauth/token" 
} 

をさらに追加することが可能です1つのクライアントとそれを行う方法? Allso、データベースからクライアントを読み取る方法は?

答えて

7

ではなく、内部で複数のwithClient Sを連結し、複数のinMemoryビルダーを使用しないでください1 inMemory

@Override 
public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 
    clients.inMemory() 
       .withClient("first") 
       .secret("secret") 
       .scopes("read") 
       .authorizedGrantTypes("password") 
      .and() 
       .withClient("sec") 
       .secret("secret") 
       .scopes("read") 
       .authorizedGrantTypes("password"); 
} 
+3

ではなくapplication.ymlファイルを経由して、これを達成することは可能ですか? –

+0

@AndreasLundgren: '.yml'ファイルで運がまだありませんでしたか? – frhd

+0

いいえ、私たちは実際にはアクセスを必要とする第三者のバックエンドシステムはなく、内部のBEシステムとクライアントだけしか持っていなかったので、oAuth2をスキップしました。 –

関連する問題