Skip to content

Commit 2ed581e

Browse files
mvetschhzalaz
authored andcommitted
Promote the "Verify Token" section (auth0#139)
[skip ci]
1 parent aee04b3 commit 2ed581e

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ The library implements JWT Verification and Signing using the following algorith
4646

4747
## Usage
4848

49-
### Decode a Token
50-
51-
```java
52-
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
53-
try {
54-
JWT jwt = JWT.decode(token);
55-
} catch (JWTDecodeException exception){
56-
//Invalid token
57-
}
58-
```
59-
60-
If the token has an invalid syntax or the header or payload are not JSONs, a `JWTDecodeException` will raise.
61-
62-
6349
### Create and Sign a Token
6450

6551
You'll first need to create a `JWTCreator` instance by calling `JWT.create()`. Use the builder to define the custom Claims your token needs to have. Finally to get the String token call `sign()` and pass the Algorithm instance.
@@ -164,6 +150,20 @@ Clock clock = new CustomClock(); //Must implement Clock interface
164150
JWTVerifier verifier = verification.build(clock);
165151
```
166152

153+
### Decode a Token
154+
155+
```java
156+
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
157+
try {
158+
JWT jwt = JWT.decode(token);
159+
} catch (JWTDecodeException exception){
160+
//Invalid token
161+
}
162+
```
163+
164+
If the token has an invalid syntax or the header or payload are not JSONs, a `JWTDecodeException` will raise.
165+
166+
167167
### Header Claims
168168

169169
#### Algorithm ("alg")

0 commit comments

Comments
 (0)