Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add readme #1

Merged
merged 1 commit into from
Nov 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Godot Engine GDScript JWT
JSON Web Token library for Godot Engine written in GDScript

## Create JWT
```gdscript
var secret: String = "<your secret token>"
var jwt_algorithm: JWTAlgorithm = JWTAlgorithm.new(HashingContext.HASH_SHA256, secret)
var jwt: String = JWT.create() \
.with_expires_at(OS.get_unix_time()) \
.with_issuer("Godot") \
.with_claim("id","someid").sign(jwt_algorithm)
print(jwt)
```

## Decode a JWT
```gdscript
var jwt: String = "<a jwt>"
var jwt_decoder : JWTDecoder = JWT.decode(jwt)
print("%s.%s.%s" % jwt_decoder.parts)
```

## Verify JWT
```gdscript
var jwt: String = "<a jwt>"
var secret: String = "<your secret token>"
var jwt_algorithm: JWTAlgorithm = JWTAlgorithm.new(HashingContext.HASH_SHA256, secret)
var jwt_verification: int = JWT.require(jwt_algorithm).verify(jwt)
if jwt_verification == JWTVerifier.Exceptions.OK :
print("Verified!")
```