79643720

Date: 2025-05-29 10:15:51
Score: 1
Natty:
Report link

It sounds like you want something that will return the list of provider ids:

Spring provides in memory repository that allows you to leverage this information, it's how Spring makes the default login page links:

https://docs.spring.io/spring-security/reference/servlet/oauth2/login/advanced.html#oauth2login-advanced-login-page

// Inject with Lombok @RequiredArgsConstructor, or use Autowired.
  private final InMemoryClientRegistrationRepository oauth2Providers;
@GetMapping("/oauth2Providers")
  public ResponseEntity<List<String>> oauth2Providers() { 
    List<String>  listOfAuth2Providers = new ArrayList<>();
    oauth2Providers.iterator().forEachRemaining(provider -> { 
      listOfAuth2Providers.add(provider.getRegistrationId());
    });
    return ResponseEntity.ofNullable(listOfAuth2Providers);
  }
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: rsandor