Skip to content

Commit c9090a0

Browse files
committed
add Header claims setter info to the README.md file
1 parent 970fb3c commit c9090a0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,18 @@ Additional Claims defined in the token's Header can be obtained by calling `getH
206206
Claim claim = jwt.getHeaderClaim("owner");
207207
```
208208

209+
When creating a Token with the `JWT.create()` you can specify header Claims by calling `withHeader()` and passing both the map of claims.
210+
211+
```java
212+
Map<String, Object> headerClaims = new HashMap();
213+
headerclaims.put("owner", "auth0");
214+
JWT.create()
215+
.withHeader(headerClaims)
216+
.sign(Algorithm.HMAC256("secret"));
217+
```
218+
219+
> The `alg` and `typ` values will always be included in the Header after the signing process.
220+
209221

210222
### Payload Claims
211223

@@ -273,14 +285,14 @@ Additional Claims defined in the token's Payload can be obtained by calling `get
273285
Map<String, Claim> claims = jwt.getClaims(); //Key is the Claim name
274286
Claim claim = claims.get("isAdmin");
275287
```
276-
al
288+
277289
or
278290

279291
```java
280292
Claim claim = jwt.getClaim("isAdmin");
281293
```
282294

283-
When creating a Token with the `JWT.create()` you can specify a custom Claim by calling `withClaim()` and passing both the name and the value.
295+
When creating a Token with the `JWT.create()` you can specify a custom Claim by calling `withClaim()` and passing both the name and the value.
284296

285297
```java
286298
JWT.create()

0 commit comments

Comments
 (0)