func (keycloak *KeycloakOAuthProvider) checkFederatedIdentity(ctx context.Context, token string, brokerEndpoint string, provider string) (bool, error) {
	req, err := http.NewRequest("GET", brokerEndpoint+"/"+provider+"/token", nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to crete http request")
		return false, er.NewInternalError("unable to crete http request " + err.Error())
	}
	req.Header.Add("Authorization", "Bearer "+token)
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"provider": provider,
			"err":      err.Error(),
		}, "Unable to obtain a federated identity token")
		return false, er.NewInternalError("Unable to obtain a federated identity token " + err.Error())
	}
	return res.StatusCode == http.StatusOK, nil
}
// checkFederatedIdentity returns true if the account is already linked to the identity provider
checkFederatedIdentity returns true if the account is already linked to the identity provider
// checkFederatedIdentity returns true if the account is already linked to the identity provider
func (keycloak *KeycloakOAuthProvider) checkFederatedIdentity(ctx context.Context, token string, brokerEndpoint string, provider string) (bool, error) {
	req, err := http.NewRequest("GET", brokerEndpoint+"/"+provider+"/token", nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to crete http request")
		return false, er.NewInternalError("unable to crete http request " + err.Error())
	}
	req.Header.Add("Authorization", "Bearer "+token)
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"provider": provider,
			"err":      err.Error(),
		}, "Unable to obtain a federated identity token")
		return false, er.NewInternalError("Unable to obtain a federated identity token " + err.Error())
	}
	return res.StatusCode == http.StatusOK, nil
}
func ( keycloak * KeycloakOAuthProvider ) checkFederatedIdentity ( ctx context . Context , token string , brokerEndpoint string , provider string ) ( bool , error ) { req , err := http . NewRequest ( " " , brokerEndpoint + " " + provider + " " , nil ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : err . Error ( ) , } , " " ) return false , er . NewInternalError ( " " + err . Error ( ) ) } req . Header . Add ( " " , " " + token ) res , err := http . DefaultClient . Do ( req ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : provider , " " : err . Error ( ) , } , " " ) return false , er . NewInternalError ( " " + err . Error ( ) ) } return res . StatusCode == http . StatusOK , nil }
checkFederatedIdentity returns true if the account is already linked to the identity provider
checkFederatedIdentity returns true if the account is already linked to the identity provider