I am crated a Spring Boot Oauth2 Authentication and worked fine. I need to add usertype field with Oauth2 response.
My Code given below.
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
static final String CLIEN_ID = "client";
//static final String CLIENT_SECRET = "devglan";
static final String CLIENT_SECRET = "$2a$04$e/c1/RfsWuTh/vj/BfG";
static final String GRANT_TYPE = "password";
static final String AUTHORIZATION_CODE = "authorization_code";
static final String REFRESH_TOKEN = "refresh_token";
static final String IMPLICIT = "implicit";
static final String SCOPE_READ = "read";
static final String SCOPE_WRITE = "write";
static final String TRUST = "trust";
static final int ACCESS_TOKEN_VALIDITY_SECONDS = 50*60*60;
static final int FREFRESH_TOKEN_VALIDITY_SECONDS = 66*60*60;
@Autowired
private TokenStore tokenStore;
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(ClientDetailsServiceConfigurer configurer) throws Exception {
configurer
.inMemory()
.withClient(CLIEN_ID)
.secret(CLIENT_SECRET)
.authorizedGrantTypes(GRANT_TYPE, AUTHORIZATION_CODE, REFRESH_TOKEN, IMPLICIT )
.scopes(SCOPE_READ, SCOPE_WRITE, TRUST)
.accessTokenValiditySeconds(ACCESS_TOKEN_VALIDITY_SECONDS).
refreshTokenValiditySeconds(FREFRESH_TOKEN_VALIDITY_SECONDS);
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore)
.authenticationManager(authenticationManager);
}
}
The Response after authentication is given below
{"access_token":"b3336423-ed9d-4d91-a308-2a5d16dbc037","token_type":"bearer","refresh_token":"135f6f95-8f5b-404a-83fc-11e12bf772be","expires_in":179999,"scope":"read write trust"}
I need to add usertype field to above response.