NKJWT 0.1.0

NKJWT 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2015

Maintained by Dmitrii Ivashko.



NKJWT 0.1.0

  • By
  • Dmitrii Ivashko

Contents:

Why NKJWT?

JWT (JSON Web Token) is an amazing technology, which makes network / API integration extremely easy and fast. This library allows you to get all benefits of JWT with only a few lines of code.

User Guide

Verifying Token

NSString *token = @"xxxxxxxxxxxx";
NKJWT *jwt = [[NKJWT alloc] initWithJWT:token];
isValid = [jwt verifyWithKey:key];

or if you do not prefer stateless expressions:

NSString *token = @"xxxxxxxxxxxx";
NKJWT *jwt = [[NKJWT alloc] initWithJWT:token];
[jwt setKey:key];
isValid = [jwt verify];

Getting Payload from token

NKJWT *jwt = [[NKJWT alloc] initWithJWT:token];
isValid = [jwt verifyWithKey:key];
NSDictionary *payload = jwt.payload;

Creating token

NKJWT *jwt = [[NKJWT alloc] initWithPayload:payloadDictionary];

Signing and getting signed token

NKJWT *jwt = [[NKJWT alloc] initWithPayload:payloadDictionary];
[jwt signWithKey:key];
NSString *token = [jwt token];

or without stateless expressions:

NKJWT *jwt = [[NKJWT alloc] initWithPayload:payloadDictionary];
[jwt setKey:key];
[jwt sign];
NSString *token = [jwt token];

Updating payload

NKJWT *jwt = [[NKJWT alloc] initWithPayload:payloadDictionary];
[jwt signWithKey:key];
NSString *token = [jwt token];

[jwt setPayload:newPayloadDictionary];
[jwt signWithKey:key];
NSString *newToken = [jwt token];