Package: io.vertx.groovy.ext.auth.oauth2

## [Groovy] Class OAuth2Auth

- io.vertx.groovy.ext.auth.oauth2.OAuth2Auth

- Factory interface for creating OAuth2 based AuthProvider instances.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `OAuth2Auth (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `OAuth2Auth` | `api(io.vertx.core.http.HttpMethod method, java.lang.String path, java.util.Map<java.lang.String, java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> handler)` Call OAuth2 APIs.
    `java.lang.String` | `authorizeURL(java.util.Map<java.lang.String, java.lang.Object> params)` Generate a redirect URL to the authN/Z backend.
    `static OAuth2Auth` | `create(Vertx vertx, io.vertx.ext.auth.oauth2.OAuth2FlowType flow, java.util.Map<java.lang.String, java.lang.Object> config)` Create a OAuth2 auth provider
    `static OAuth2Auth` | `create(Vertx vertx, io.vertx.ext.auth.oauth2.OAuth2FlowType flow)` Create a OAuth2 auth provider
    `static OAuth2Auth` | `createKeycloak(Vertx vertx, io.vertx.ext.auth.oauth2.OAuth2FlowType flow, java.util.Map<java.lang.String, java.lang.Object> config)` Create a OAuth2 auth provider
    `java.lang.Object` | `getDelegate()`
    `void` | `getToken(java.util.Map<java.lang.String, java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<AccessToken>> handler)` Returns the Access Token object.
    `boolean` | `hasJWTToken()` Returns true if this provider supports JWT tokens as the access_token.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AuthProvider` | `authenticate, getDelegate`
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### OAuth2Auth(java.lang.Object delegate)

  - ### Method Detail

    - #### OAuth2Auth api(io.vertx.core.http.HttpMethod method, java.lang.String path, java.util.Map<java.lang.String, java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> handler)

      Call OAuth2 APIs.

      Returns:
        self
      Parameters:
        `method` - HttpMethod
        `path` - target path
        `params` - parameters
        `handler` - handler

    - #### java.lang.String authorizeURL(java.util.Map<java.lang.String, java.lang.Object> params)

      Generate a redirect URL to the authN/Z backend. It only applies to auth_code flow.

      Returns:
      Parameters:
        params

    - #### static OAuth2Auth create(Vertx vertx, io.vertx.ext.auth.oauth2.OAuth2FlowType flow, java.util.Map<java.lang.String, java.lang.Object> config)

      Create a OAuth2 auth provider

      Returns:
        the auth provider
      Parameters:
        `vertx` - the Vertx instance
        flow
        `config` - the config (see OAuth2ClientOptions)

    - #### static OAuth2Auth create(Vertx vertx, io.vertx.ext.auth.oauth2.OAuth2FlowType flow)

      Create a OAuth2 auth provider

      Returns:
        the auth provider
      Parameters:
        `vertx` - the Vertx instance
        flow

    - #### static OAuth2Auth createKeycloak(Vertx vertx, io.vertx.ext.auth.oauth2.OAuth2FlowType flow, java.util.Map<java.lang.String, java.lang.Object> config)

      Create a OAuth2 auth provider

      Returns:
        the auth provider
      Parameters:
        `vertx` - the Vertx instance
        flow
        `config` - the config as exported from the admin console

    - #### java.lang.Object getDelegate()

    - #### void getToken(java.util.Map<java.lang.String, java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<AccessToken>> handler)

      Returns the Access Token object.

      Parameters:
        `params` - - JSON with the options, each flow requires different options.
        `handler` - - The handler returning the results.

    - #### boolean hasJWTToken()

      Returns true if this provider supports JWT tokens as the access_token. This is typically true if the provider implements the `openid-connect` protocol. This is a plain return from the config option jwtToken, which is false by default. This information is important to validate grants. Since pure OAuth2 should be used for authorization and when a token is requested all grants should be declared, in case of openid-connect this is not true. OpenId will issue a token and all grants will be encoded on the token itself so the requester does not need to list the required grants.

      Returns:
        true if openid-connect is used.