Open Source iOS Library For Easily Decoding JSON Web Tokens (JWTs)

JSON web tokens are a common way to pass data safely through the web, and here’s an open source library from Auth0 submitted by Martin Gontovnikas for decoding JWTs.

The library provides methods for easily extracting JSON data and expiry dates from the web tokens, and also provides convenience methods for checking whether the web token is expired.

This example from the readme shows how to decode a web token in Swift:

let jwt = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL3NhbXBsZXMuYXV0aDAuY29tLyIsInN1YiI6ImZhY2Vib29rfDEwMTU0Mjg3MDI3NTEwMzAyIiwiYXVkIjoiQlVJSlNXOXg2MHNJSEJ3OEtkOUVtQ2JqOGVESUZ4REMiLCJleHAiOjE0MTIyMzQ3MzAsImlhdCI6MTQxMjE5ODczMH0.7M5sAV50fF1-_h9qVbdSgqAnXVF7mz3I6RjS6JiH0H8"
var error:NSError?
let payload = A0JWTDecoder.payloadOfJWT(jwt, error: &error)
println("JWT payload is :")

You can find JWTDecode.iOS on Github here.

A nice easy way to decode JSON Web TOkens.

FacebookTwitterDiggStumbleUponGoogle Plus

Original article: Open Source iOS Library For Easily Decoding JSON Web Tokens (JWTs)

©2014 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *