-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathExampleJWT.java
More file actions
25 lines (22 loc) · 841 Bytes
/
ExampleJWT.java
File metadata and controls
25 lines (22 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import com.plivo.api.AccessToken;
import java.time.Instant;
import java.util.Date;
import java.time.Duration;
class ExampleJWT {
public static void main(String [] args) throws Exception {
// auth_id, auth_token and endpoint username are mandatory
AccessToken acctkn0 = new AccessToken("MADADADADADADADADADA", "auth_token", "username")
.ValidFrom(Date.from(Instant.now()))
.Lifetime(Duration.ofMillis(300000))
.AllowIncoming(true)
.AllowOutgoing(false);
System.out.println(acctkn0.toJwt());
AccessToken acctkn1 = new AccessToken("MADADADADADADADADADA", "auth_token", "username")
.ValidFrom(Date.from(Instant.now()))
.ValidTill(Date.from(Instant.now().plusSeconds(300)))
.AllowIncoming(true)
.AllowOutgoing(false);
System.out.println(acctkn1.toJwt());
return;
}
}