Get Updates By E-mail 

Article Written By:
Johann Dowa

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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments