Closed HSV24 closed 3 months ago
No there isn't - an access token would have an expiration time. What you can do is build your own TokenCredential class that uses whatever magic behind the scenes to be able to deliver new access tokens when requested. But none of that has anything to do with Cosmos DB - it is purely azure-core/azure-identity usage.
The TokenCredential interface is here: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/credential/TokenCredential.java
Query/Question Cx is trying to establish connection with their cosmos DB using cosmosclientbuilder class. This is takes the tokencredential to get an access token from AAD and establish the connection. https://learn.microsoft.com/en-us/java/api/com.azure.cosmos.cosmosclientbuilder?view=azure-java-stable So, we define all the necessary values such as tenant id. client id and secret etc for tokencredential and pass it on the builder to get access token itself and use it.
However, due to cx network requirements, they restricted the access to login.microsoftonline.com URL from their environment. So the above builder could not establish connection with cosmosDB as it is unable to get token and tokencredetnial requires login.microsoftonline.com to get token successfully.
As a workaround, cx is able to get a token from their other environment. However, we are unable to pass this token to the builder. Seems the cosmos builder only accepts as tokencredential and not as an access token. So they are getting format error.
Now we would like to know is there any way to convert this retrieved access token to token credential format that can be utilized in cosmosclientbuilder class.