fenix-hub / godot-engine.jwt

JSON Web Token library for Godot Engine written in GDScript
https://nicolosantilio.com/godot-engine.jwt
MIT License
51 stars 11 forks source link

Invalid type in JWTDecoder function parse #14

Closed AnasASK closed 2 years ago

AnasASK commented 2 years ago

in JWTDecoder.gd:

func _init(jwt: String):
    self.parts = jwt.split(".")
    var header: PoolByteArray = JWTUtils.base64URL_decode(self.parts[0])
    var payload: PoolByteArray = JWTUtils.base64URL_decode(self.parts[1])
    self.header_claims = _parse_json(header)
    self.payload_claims = _parse_json(payload)

func _parse_json(field) -> Dictionary:
    var parse_result: JSONParseResult = JSON.parse(field)
    if parse_result.error != OK:
        return {}
    return parse_result.result

JSON.parse(field) field should be a string according to godot docs, but here a PoolByteArray is passed instead

fenix-hub commented 2 years ago

Looks like you are using a version from dev branch, try installing the plugin from main if you are using 3.x instead, or from 4.x if you are using Godot 4.0 and later

AnasASK commented 2 years ago

I downloaded it from the releases, I will try installing from the master branch.

fenix-hub commented 2 years ago

Thanks, I forgot to make releases in a while, I'll make a new one just now so you can use it

AnasASK commented 2 years ago

Thanks it is working