Skip to content

Commit 4b84222

Browse files
committed
chore: add note for how to sign jwts in the readme
1 parent 182ea5e commit 4b84222

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,19 @@ client.notify(
6565
}
6666
)
6767
```
68+
69+
### Signing JWTs
70+
71+
You can use the `pyjwt` package to [sign JWTs easily](https://pyjwt.readthedocs.io/en/stable/usage.html#encoding-decoding-tokens-with-rs256-rsa).
72+
You will need to generate an environment specific signing key, which you can find in the Knock dashboard.
73+
74+
If you're using a signing token you will need to pass this to your client to perform authentication.
75+
You can read more about [clientside authentication here](https://docs.knock.app/client-integration/authenticating-users).
76+
77+
```python
78+
from jwt
79+
import os
80+
81+
private_key = os.getenv("KNOCK_SIGNING_KEY")
82+
encoded = jwt.encode({"sub": "jhammond"}, private_key, algorithm="RS256")
83+
```

0 commit comments

Comments
 (0)