Skip to content

Commit

Permalink
uptaking review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AsabuHere committed Jun 24, 2024
1 parent 3e82989 commit d6469b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,10 @@ public class Example {
```
### Initialize the client when endpoints does not use basic authentication
The above example shows how to initialize the client in case the endpoints use basic authentication. When the endpoint does not require any authentication, use TwilioNoAuth client instead.
Also there are endpoints like Organization domain which uses bearer token authentication. Custom Clients needs to be used in such cases and initialize them with the values required for access token generation

```java
import com.twilio.TwilioOrgsTokenAuth;
import com.twilio.exception.AuthenticationException;

public class Example {

private static final String GRANT_TYPE = "grant_type_to_be_used";
private static final String CLIENT_SID =
"client_id_of_the_organization";
private static final String CLIENT_SECRET = "client_secret_of_organization";

public static void main(String[] args) throws AuthenticationException {
TwilioOrgsTokenAuth.init(GRANT_TYPE, CLIENT_SID, CLIENT_SECRET);
}
}
```
There are endpoints like Organization domain which uses bearer token authentication. Custom Clients needs to be used in such cases and initialize them with the values required for access token generation.

To bypass the initialization step you can also use a custom token manager implementation. Token manager class should implement the Token interface and call a token generation endpoint of your choice.
Detailed example [here](https://github.com/twilio/twilio-java/tree/main/examples)
Detailed examples [here](https://github.com/twilio/twilio-java/tree/main/examples)

### Environment Variables

Expand Down
9 changes: 8 additions & 1 deletion examples/BearerTokenAuthentication.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
class BearerTokenAuthenticationExamples {
public static void main {

private static final String GRANT_TYPE = "grant_type_to_be_used";
private static final String CLIENT_SID =
"client_id_of_the_organization";
private static final String CLIENT_SECRET = "client_secret_of_organization";
private static final String ORGANISATION_ID = "id_of_the_organization";

//Getting access token - Method #1
TwilioOrgsTokenAuth.init(GRANT_TYPE, CLIENT_ID, CLIENT_SECRET);

//Getting access token - Method #2
//To provide custom token manager implementation
//Need not call init method if customer token manager is passed
//TwilioOrgsTokenAuth.setTokenManager(new OrgsTokenManager(grantType, clientId, clientSecret));
//TwilioOrgsTokenAuth.setTokenManager(new CustomTokenManagerImpl(GRANT_TYPE, CLIENT_ID, CLIENT_SECRET));

fetchAccountDetails();
}
Expand Down

0 comments on commit d6469b5

Please sign in to comment.