What I'm trying to do is to add an extra parameter openid.realm to my authorization request.
My problem is very similar to https://github.com/spring-projects/spring-security-oauth/issues/123 and I tried to follow the outlined to way solve it:
// Create an enhancer that adds openid.realm
DefaultRequestEnhancer enhancer = new DefaultRequestEnhancer();
enhancer.setParameterIncludes(Arrays.asList("openid.realm"));
// Create tokenprovider that use the enhancer
AuthorizationCodeAccessTokenProvider tokenProvider =
new AuthorizationCodeAccessTokenProvider();
tokenProvider.setAuthorizationRequestEnhancer(enhancer);
// Give the tokenProvider to the rest template
googleOauthRestTemplate.setAccessTokenProvider(tokenProvider);
googleOauthRestTemplate.
getOAuth2ClientContext().
getAccessTokenRequest().set("openid.realm", "http://localhost:8080/");
// Try to get the protected resource …Run Code Online (Sandbox Code Playgroud) 我试图保持jslint排除尽可能接近错误,以免错误地隐藏任何错误.示例中未使用的参数在x函数中f2,我只想排除这种情况.
第一个示例,不包括周围的函数,但会隐藏其他错误,如果有的话:
/*jslint unparam: true*/
function test1() {
var f1 = function (x) {
alert(x);
},
f2 = function (x) {};
f1(0);
f2(0);
}
/*jslint unparam: false*/
Run Code Online (Sandbox Code Playgroud)
围绕var语句也有效,但会隐藏错误f1:
function test2() {
/*jslint unparam: true*/
var f1 = function (x) {
alert(x);
},
f2 = function (x) {};
/*jslint unparam: false*/
f1(0);
f2(0);
}
Run Code Online (Sandbox Code Playgroud)
这个产生一个错误:"预期一个标识符,而是看到'/*jslint'(一个保留字)."
function test3() {
var f1 = function (x) {
alert(x);
},
/*jslint unparam: true*/
f2 = function (x) {};
/*jslint …Run Code Online (Sandbox Code Playgroud)