Skip to content

Commit 9b4ddd7

Browse files
rujchejgrandja
authored andcommitted
Make AuthorizationGrantTypeConverter support custom grant type
Closes gh-10155
1 parent d0fbe6b commit 9b4ddd7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/jackson2/StdConverters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ public AuthorizationGrantType convert(JsonNode jsonNode) {
8383
if (AuthorizationGrantType.PASSWORD.getValue().equalsIgnoreCase(value)) {
8484
return AuthorizationGrantType.PASSWORD;
8585
}
86-
return null;
86+
return new AuthorizationGrantType(value);
8787
}
8888

8989
}

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/jackson2/OAuth2AuthorizedClientMixinTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
3333
import org.springframework.security.oauth2.client.registration.ClientRegistration;
3434
import org.springframework.security.oauth2.client.registration.TestClientRegistrations;
35+
import org.springframework.security.oauth2.core.AuthorizationGrantType;
3536
import org.springframework.security.oauth2.core.OAuth2AccessToken;
3637
import org.springframework.security.oauth2.core.OAuth2RefreshToken;
3738
import org.springframework.security.oauth2.core.TestOAuth2AccessTokens;
@@ -69,6 +70,7 @@ public void setup() {
6970
providerConfigurationMetadata.put("config2", "value2");
7071
// @formatter:off
7172
this.clientRegistrationBuilder = TestClientRegistrations.clientRegistration()
73+
.authorizationGrantType(new AuthorizationGrantType("custom-grant"))
7274
.scope("read", "write")
7375
.providerConfigurationMetadata(providerConfigurationMetadata);
7476
// @formatter:on

0 commit comments

Comments
 (0)