spring-attic / spring-social

Allows you to connect your applications with SaaS providers such as Facebook and Twitter.
http://projects.spring.io/spring-social
Apache License 2.0
619 stars 351 forks source link

Set scope not being used in built OAuth2 URL #178

Closed andrewferk closed 9 years ago

andrewferk commented 9 years ago

I followed the guide for implementing my own provider and have used others as a reference. We require a scope to be provided when hitting our OAuth2 endpoints, and I'd prefer if the scope can be configured when we create our connection factory:

MyConnectionFactory mycf = new MyConnectionFactory("clientId", "clientSecret");
mycf.setScope("myApi");
cfConfig.addConnectionFactory(mycf);

However, this scope never makes it to the OAuth2AuthenticationService. When OAuth2AuthenticationService#setScope executes, defaultScope is still an empty string. The defaultScope is supposed to be set within SecurityEnabledConnectionFactoryConfigurer#wrapAsAuthenticationService, but nothing seems to get executed after the final OAuth2AuthenticationService<A> authService = ... line (I set breakpoints, logs and system out).

I don't know what could be preventing the next line to be run, but because it's not running the default scope is never being set.

The workaround is to set the scope as a url parameter, but I'd prefer this to be coded in config.

habuma commented 9 years ago

This is odd. In all of the tests I've run, it does make it to that next line and the default scope is set. Would it be possible for you to share what you have (or some facsimile thereof) for me to try?

I can't think of too many things that would prevent that line from running. The only 2 I've come up with are:

(1) An exception is thrown from the previous line where OAuth2AuthenticationService is created. (Even then, I can't imagine what exception would be thrown) (2) Maybe you are seeing this behavior in a debugger that is showing the current version of the code but the actual executable in play is an older version that doesn't have that line. I've had this kind of thing happen to me from time to time and it can be terribly confusing. If the method is returning immediately after that "final" line, I'd bet that this is what's happening.

andrewferk commented 9 years ago

Thanks. It was (2). I was using an outdated version of spring-social-samples that was still referencing spring social 1.1.0.