How to find out the valid values to use for authorized grant types in Spring Secrity

Viewed 1768

I want to allow a client to use a specific grant type, but cannot find the valid values to use in the client table in the documentation.

Any ideas?

2 Answers

Here is something I use regularly:

public enum OAuth2GrantTypes {

    AUTHORIZATION_CODE("authorization_code"),
    IMPLICIT("implicit"),
    PASSWORD("password"),
    CLIENT_CREDENTIALS("client_credentials"),
    REFRESH_TOKEN("refresh_token");

    // Currently not supported by Spring Security
    // https://tools.ietf.org/html/draft-ietf-oauth-device-flow-01
    // DEVICE_CODE("device_code")

    private final String name;

    OAuth2GrantTypes(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}

This allows you to specify the grant types like this:

.authorizedGrantTypes(
    OAuth2GrantTypes.IMPLICIT.getName()
)
Related