{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5011","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5011/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5011/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5011/events","html_url":"https://github.com/spring-projects/spring-boot/issues/5011","id":128227902,"number":5011,"title":"oauth2 rest operation configuration invalid with @EnableOAuth2Client","user":{"login":"fkowal","id":512798,"avatar_url":"https://avatars.githubusercontent.com/u/512798?v=3","gravatar_id":"","url":"https://api.github.com/users/fkowal","html_url":"https://github.com/fkowal","followers_url":"https://api.github.com/users/fkowal/followers","following_url":"https://api.github.com/users/fkowal/following{/other_user}","gists_url":"https://api.github.com/users/fkowal/gists{/gist_id}","starred_url":"https://api.github.com/users/fkowal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fkowal/subscriptions","organizations_url":"https://api.github.com/users/fkowal/orgs","repos_url":"https://api.github.com/users/fkowal/repos","events_url":"https://api.github.com/users/fkowal/events{/privacy}","received_events_url":"https://api.github.com/users/fkowal/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"dsyer","id":124075,"avatar_url":"https://avatars.githubusercontent.com/u/124075?v=3","gravatar_id":"","url":"https://api.github.com/users/dsyer","html_url":"https://github.com/dsyer","followers_url":"https://api.github.com/users/dsyer/followers","following_url":"https://api.github.com/users/dsyer/following{/other_user}","gists_url":"https://api.github.com/users/dsyer/gists{/gist_id}","starred_url":"https://api.github.com/users/dsyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsyer/subscriptions","organizations_url":"https://api.github.com/users/dsyer/orgs","repos_url":"https://api.github.com/users/dsyer/repos","events_url":"https://api.github.com/users/dsyer/events{/privacy}","received_events_url":"https://api.github.com/users/dsyer/received_events","type":"User","site_admin":false},"assignees":[{"login":"dsyer","id":124075,"avatar_url":"https://avatars.githubusercontent.com/u/124075?v=3","gravatar_id":"","url":"https://api.github.com/users/dsyer","html_url":"https://github.com/dsyer","followers_url":"https://api.github.com/users/dsyer/followers","following_url":"https://api.github.com/users/dsyer/following{/other_user}","gists_url":"https://api.github.com/users/dsyer/gists{/gist_id}","starred_url":"https://api.github.com/users/dsyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsyer/subscriptions","organizations_url":"https://api.github.com/users/dsyer/orgs","repos_url":"https://api.github.com/users/dsyer/repos","events_url":"https://api.github.com/users/dsyer/events{/privacy}","received_events_url":"https://api.github.com/users/dsyer/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/73","html_url":"https://github.com/spring-projects/spring-boot/milestones/1.4.2","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/73/labels","id":2018289,"number":73,"title":"1.4.2","description":"","creator":{"login":"snicoll","id":490484,"avatar_url":"https://avatars.githubusercontent.com/u/490484?v=3","gravatar_id":"","url":"https://api.github.com/users/snicoll","html_url":"https://github.com/snicoll","followers_url":"https://api.github.com/users/snicoll/followers","following_url":"https://api.github.com/users/snicoll/following{/other_user}","gists_url":"https://api.github.com/users/snicoll/gists{/gist_id}","starred_url":"https://api.github.com/users/snicoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snicoll/subscriptions","organizations_url":"https://api.github.com/users/snicoll/orgs","repos_url":"https://api.github.com/users/snicoll/repos","events_url":"https://api.github.com/users/snicoll/events{/privacy}","received_events_url":"https://api.github.com/users/snicoll/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":8,"state":"open","created_at":"2016-09-21T06:34:26Z","updated_at":"2016-09-28T20:54:56Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-01-22T19:36:14Z","updated_at":"2016-09-28T23:07:44Z","closed_at":null,"body":"I have a web application, configured like this\r\n```\r\nsecurity:\r\n  basic.enabled: false\r\n  sessions: stateless\r\n  oauth2:\r\n    client:\r\n      id: 'id'\r\n      grant-type: client_credentials\r\n      client-id: client_id\r\n      client-secret: secret\r\n      scope: myscope\r\n      access-token-uri: http://someuri/oauth/token\r\n    resource:\r\n      jwt.key-uri: http://someuri/oauth/token_key\r\n```\r\n\r\nI @EnableOAuth2Client hoping that OAuthRestTemplate would use client_credentials on use.\r\n\r\nsadly OAuth2RestOperationsConfiguration has the following code:\r\n```\t@Configuration\r\n\tprotected abstract static class BaseConfiguration {\r\n\r\n\t\t@Bean\r\n\t\t@ConfigurationProperties(\"security.oauth2.client\")\r\n\t\t@Primary\r\n\t\tpublic AuthorizationCodeResourceDetails oauth2RemoteResource() {\r\n\t\t\tAuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();\r\n\t\t\treturn details;\r\n\t\t}\r\n\r\n\t}\r\n\r\n\t@Configuration\r\n\t@ConditionalOnNotWebApplication\r\n\tprotected static class SingletonScopedConfiguration {\r\n\r\n\t\t@Bean\r\n\t\t@ConfigurationProperties(\"security.oauth2.client\")\r\n\t\t@Primary\r\n\t\tpublic ClientCredentialsResourceDetails oauth2RemoteResource() {\r\n\t\t\tClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();\r\n\t\t\treturn details;\r\n\t\t}\r\n\r\n\t\t@Bean\r\n\t\tpublic DefaultOAuth2ClientContext oauth2ClientContext() {\r\n\t\t\treturn new DefaultOAuth2ClientContext(new DefaultAccessTokenRequest());\r\n\t\t}\r\n\r\n\t}\r\n```\r\n\r\nSingletonScopedConfiguration is not used because of ConditionalOnNotWebApplication\r\n\r\nAuthorizationCodeResourceDetails is created BUT the grant_type is overriden and set to *client_credentials* :/. This causes AuthorizationCodeAccessTokenProvider to fail on \r\n```\r\npublic boolean supportsResource(OAuth2ProtectedResourceDetails resource) {\r\n\t\treturn resource instanceof AuthorizationCodeResourceDetails\r\n\t\t\t\t&& \"authorization_code\".equals(resource.getGrantType());\r\n\t}\r\n```\r\n\r\nCan i make a pull request changing @ConditionalOnNotWebApplication\r\nto @ConditionalOnProperty(value=\"spring.oauth2.client.grant-type\", havingValue=\"client-credentials\") ?"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/250327455","html_url":"https://github.com/spring-projects/spring-boot/issues/5011#issuecomment-250327455","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/5011","id":250327455,"user":{"login":"dsyer","id":124075,"avatar_url":"https://avatars.githubusercontent.com/u/124075?v=3","gravatar_id":"","url":"https://api.github.com/users/dsyer","html_url":"https://github.com/dsyer","followers_url":"https://api.github.com/users/dsyer/followers","following_url":"https://api.github.com/users/dsyer/following{/other_user}","gists_url":"https://api.github.com/users/dsyer/gists{/gist_id}","starred_url":"https://api.github.com/users/dsyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsyer/subscriptions","organizations_url":"https://api.github.com/users/dsyer/orgs","repos_url":"https://api.github.com/users/dsyer/repos","events_url":"https://api.github.com/users/dsyer/events{/privacy}","received_events_url":"https://api.github.com/users/dsyer/received_events","type":"User","site_admin":false},"created_at":"2016-09-28T23:07:44Z","updated_at":"2016-09-28T23:07:44Z","body":"I guess I don't mind. Lots of people asking about it now, is all, and 1.5 is not ready yet."}}
{"actor":{"display_login":"dsyer"}}