opened
ellismg
username_0
Unlike our other libraries, which fail to load a token from the cache when there are multiple identities and a username has not been specified, the Java implementation of SharedTokenCacheCredential will simply use the first entry in the cache.

While I love not having to have someone set `AZURE_USERNAME` and have things "just work" I think we should tighten our default behavior here such that if the cache has multiple entries, we require that a username be specified.

Concretely, I think we should add some code around [here](https://github.com/Azure/azure-sdk-for-java/blob/33f496228cc24442e1a8e0aa3e9a5d36b3eba8e8/sdk/identity/azure-identity/src/main/java/com/azure/identity/credential/SharedTokenCacheCredential.java#L76-L90) that returns a `Mono.error` if `username` is null and `collection` has more than one entry.  I think this is better than just picking the first entry (since it's not clear that this collection is "ordered").
[BUG] SharedTokenCache credential does not fail when multiple identities in the cache and no `AZURE_USERNAME` is set
issue
closed
jianghaolu
username_1
issue