Skip to content

Sample code given in readme returns an error. #110

Open
@bibinjacobpulickal

Description

@bibinjacobpulickal

This is the sample code given for decoding a jwt gives an error "Failed to decode JWT: Unsupported algorithm or incorrect key", which is really undesirable from a developers perspective. I also, tried decoding my string that didn't work either
do { let claims: ClaimSet = try JWT.decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w", algorithm: .hs256("secret".data(using: .utf8)!)) print(claims) } catch { print("Failed to decode JWT: \(error)") }
This was my string:
"eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2NhcGkuZGJzLmNvbSIsImlhdCI6MTUzMDI1MzE0MzIyOSwiZXhwIjoxNTMwMjU2NzQzMjI5LCJzdWIiOiJTVmN3TXpZPSIsInB0eXR5cGUiOjEsImNsbmlkIjoiY2xpZW50SWQyIiwiY2xudHlwZSI6IjIiLCJhY2Nlc3MiOiIxRkEiLCJzY29wZSI6IjJGQS1TTVMiLCJhdWQiOiJodHRwczovL2NhcGkuZGJzLmNvbS9hY2Nlc3MiLCJqdGkiOiI1OTc1OTE1ODk4MjQ1MDYwMjQ2IiwiY2luIjoiVXpFeE5USXlOREZHIn0.PnCyow4gk3-i5odLy81eJ_G-uU_DQAmkvWAIHpRraBQ"
screen shot 2018-06-29 at 13 08 42

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions