I am trying to use the searchClient library:
service_endpoint = os.environ["AZURE_SEARCH_SERVICE_ENDPOINT"]
index_name = os.environ["AZURE_SEARCH_INDEX_NAME"]
key = os.environ["AZURE_SEARCH_API_KEY"]
search_client = SearchClient(service_endpoint, index_name, AzureKeyCredential(key))
Is there a way to create the searchclient by passing a token instead of an API or another way to authenticate without this api key?
As @Gaurav Mantri mentioned, you need to use
DefaultAzureCredentialto authorize through a token.Here is the corrected code:
DefaultAzureCredentialauthenticates through various mechanisms. Learn more about it here.Output:
Ensure you provide all required roles for accessing the AI search service.