-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced ChatUserCredentialPolicy with BearerTokenAuthenticationPolicy
- Loading branch information
1 parent
3540be5
commit 4fafb6d
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ion-common/src/main/java/com/azure/communication/common/CommunicationTokenCredential.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.communication.common; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
|
||
import com.azure.core.credential.AccessToken; | ||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.core.credential.TokenRequestContext; | ||
|
||
import reactor.core.publisher.Mono; | ||
|
||
public class CommunicationTokenCredential implements TokenCredential { | ||
private CommunicationUserCredential credential; | ||
|
||
public CommunicationTokenCredential(CommunicationUserCredential communicationUserCrendential){ | ||
credential = communicationUserCrendential; | ||
} | ||
|
||
@Override | ||
public Mono<AccessToken> getToken(TokenRequestContext request){ | ||
try{ | ||
return Mono.just(credential.getToken().get()); | ||
} | ||
catch (InterruptedException ex) { | ||
return Mono.error(ex); | ||
} catch (ExecutionException ex) { | ||
return Mono.error(ex); | ||
} | ||
} | ||
} |