java.lang.Object
com.irurueta.authserver.authorization.infrastructure.github.GitHubUsersApiFactory

@Component public class GitHubUsersApiFactory extends Object
Builds the users client generated from the GitHub contract for one call. The generated ApiClient keeps its base path and bearer token as mutable state, and both change with every sign-in (the base path comes from the registration, the token from the user), so a shared instance would mix the calls of concurrent sign-ins: each call gets its own client on top of one shared, thread-safe RestClient.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.springframework.web.client.RestClient
    HTTP client every generated client sends its requests through.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GitHubUsersApiFactory(org.springframework.web.client.RestClient.Builder builder)
    Creates the factory.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(String basePath, String accessToken)
    Builds the client of one call.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • restClient

      private final org.springframework.web.client.RestClient restClient
      HTTP client every generated client sends its requests through.
  • Constructor Details

    • GitHubUsersApiFactory

      public GitHubUsersApiFactory(org.springframework.web.client.RestClient.Builder builder)
      Creates the factory.
      Parameters:
      builder - builder of REST clients configured by Spring Boot (message converters, observations).
  • Method Details

    • create

      public UsersApi create(String basePath, String accessToken)
      Builds the client of one call.
      Parameters:
      basePath - base URI of GitHub's API, without a trailing slash.
      accessToken - GitHub access token of the user, sent as the bearer token.
      Returns:
      the generated users client.