Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OAuth2WebClient

An asynchronous OAuth2/OIDC aware HTTP / HTTP/2 client called WebClientOAuth2.

This client wraps a WebClient and makes it session aware adding features to it:

  • Request an access_token if no user is created
  • Refresh access_token if current user is expired

Hierarchy

Index

Methods

close

  • close(): void
  • Close the client. Closing will close down any pooled connections. Clients should always be closed after use.

    Returns void

delete

  • delete(requestURI: string): HttpRequest<Buffer>
  • delete(requestURI: UriTemplate): HttpRequest<Buffer>
  • delete(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • delete(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • delete(host: string, requestURI: string): HttpRequest<Buffer>
  • delete(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP DELETE request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

deleteAbs

  • deleteAbs(absoluteURI: string): HttpRequest<Buffer>
  • deleteAbs(absoluteURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

get

  • get(requestURI: string): HttpRequest<Buffer>
  • get(requestURI: UriTemplate): HttpRequest<Buffer>
  • get(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • get(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • get(host: string, requestURI: string): HttpRequest<Buffer>
  • get(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP GET request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

getAbs

  • Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

head

  • head(requestURI: string): HttpRequest<Buffer>
  • head(requestURI: UriTemplate): HttpRequest<Buffer>
  • head(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • head(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • head(host: string, requestURI: string): HttpRequest<Buffer>
  • head(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP HEAD request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

headAbs

  • Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

patch

  • patch(requestURI: string): HttpRequest<Buffer>
  • patch(requestURI: UriTemplate): HttpRequest<Buffer>
  • patch(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • patch(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • patch(host: string, requestURI: string): HttpRequest<Buffer>
  • patch(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP PATCH request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

patchAbs

  • Create an HTTP PATCH request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

post

  • post(requestURI: string): HttpRequest<Buffer>
  • post(requestURI: UriTemplate): HttpRequest<Buffer>
  • post(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • post(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • post(host: string, requestURI: string): HttpRequest<Buffer>
  • post(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP POST request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

postAbs

  • Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

put

  • put(requestURI: string): HttpRequest<Buffer>
  • put(requestURI: UriTemplate): HttpRequest<Buffer>
  • put(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • put(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • put(host: string, requestURI: string): HttpRequest<Buffer>
  • put(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP PUT request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

putAbs

  • Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

request

  • request(method: HttpMethod, port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, options: RequestOptions): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, options: RequestOptions): HttpRequest<Buffer>
  • Create an HTTP request to send to the server at the specified host and port.

    Parameters

    • method: HttpMethod
    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and port.

    Parameters

    • method: HttpMethod
    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the port and host parameters.

    The request host header will still be created from the port and host parameters.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the port and host parameters.

    The request host header will still be created from the port and host parameters.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and default port.

    Parameters

    • method: HttpMethod
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and default port.

    Parameters

    • method: HttpMethod
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and host parameter.

    The request host header will still be created from the default port and host parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and host parameter.

    The request host header will still be created from the default port and host parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the default host and port.

    Parameters

    • method: HttpMethod
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the default host and port.

    Parameters

    • method: HttpMethod
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and default host.

    The request host header will still be created from the default port and default host.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and default host.

    The request host header will still be created from the default port and default host.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and port.

    Parameters

    • method: HttpMethod
    • options: RequestOptions

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the options parameter.

    The request host header will still be created from the options parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • options: RequestOptions

    Returns HttpRequest<Buffer>

requestAbs

  • requestAbs(method: HttpMethod, absoluteURI: string): HttpRequest<Buffer>
  • requestAbs(method: HttpMethod, absoluteURI: UriTemplate): HttpRequest<Buffer>
  • requestAbs(method: HttpMethod, serverAddress: SocketAddress, absoluteURI: string): HttpRequest<Buffer>
  • requestAbs(method: HttpMethod, serverAddress: SocketAddress, absoluteURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP request to send to the server using an absolute URI

    Parameters

    • method: HttpMethod
    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server using an absolute URI

    Parameters

    • method: HttpMethod
    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#requestAbs} using the serverAddress parameter to connect to the server instead of the absoluteURI parameter.

    The request host header will still be created from the absoluteURI parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#requestAbs} using the serverAddress parameter to connect to the server instead of the absoluteURI parameter.

    The request host header will still be created from the absoluteURI parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

withCredentials

  • Mark that request should be dispatched with authentication obtained from passed OAuth2Auth provider

    Parameters

    • credentials: any

    Returns OAuth2WebClient

Static create

  • Create a session aware web client using the provided webClient instance.

    Parameters

    • webClient: WebClient
    • oAuth2Auth: OAuth2Auth

    Returns OAuth2WebClient

  • Create a session aware web client using the provided webClient instance.

    Parameters

    Returns OAuth2WebClient

Static wrap

  • Wrap an httpClient with a web client and default options.

    Parameters

    • httpClient: HttpClient

    Returns WebClient

  • Wrap an httpClient with a web client and default options.

    Only the specific web client portion of the options is used, the HttpClientOptions of the httpClient is reused.

    Parameters

    Returns WebClient

Generated using TypeDoc