### Install JWT Pod Source: https://cocoapods.org/pods/JWT Add this line to your Podfile to include the JWT library in your project. Then run 'pod install'. ```ruby target 'MyApp' do pod 'JWT', '3.0.0-beta.14' end ``` -------------------------------- ### Install JWT via Carthage Source: https://cocoapods.org/pods/JWT Use this command in your Cartfile to manage the JWT library dependency. ```bash github "yourkarma/JWT" "master" ``` -------------------------------- ### Install JWT via CocoaPods Source: https://cocoapods.org/pods/JWT Add this line to your Podfile to include the JWT library in your project. ```ruby pod "JWT" ``` -------------------------------- ### EC Algorithms Support with PEM Keys Source: https://cocoapods.org/pods/JWT Example of initializing JWTCryptoKey objects using PEM-encoded public and private keys for EC algorithms. Ensure keys are in ANSI X9.63 format. ```objective-c NSString *privateKeyString = @""; NSString *publicKeyString = @""; // Note: We should pass type of key. Default type is RSA. NSDictionary *parameters = @{JWTCryptoKey.parametersKeyBuilder : JWTCryptoKeyBuilder.new.keyTypeEC}; id privateKey = [[JWTCryptoKeyPrivate alloc] initWithPemEncoded:privateKeyString parameters:parameters error:nil]; id publicKey = [[JWTCryptoKeyPublic alloc] initWithPemEncoded:publicKeyString parameters:parameters error:nil]; // Note: JWTAlgorithmRSFamilyDataHolder will be renamed to something more appropriate. It can holds any asymmetric keys pair (private and public). id holder = [JWTAlgorithmRSFamilyDataHolder new].signKey(privateKey).verifyKey(publicKey).algorithmName(JWTAlgorithmNameES256); ``` -------------------------------- ### Decode JWT with Multiple Secrets Source: https://cocoapods.org/pods/JWT Example of decoding a JWT when multiple potential secrets are available. The library will attempt to decode the token with each secret provided. ```objective-c // possible that your algorithm has several secrets. // you don't know which secret to use. // but you want to decode it. NSString *firstSecret = @"first"; NSArray *manySecrets = @[@"second", @"third", @"forty two"]; // translate to data NSArray *manySecretsData = @[]; for (NSString *secret in manySecrets) { NSData *secretData = [JWTBase64Coder dataWithBase64UrlEncodedString:secret]; if (secret) { manySecretsData = [manySecretsData arrayByAddingObject:secretData]; } } NSString *algorithmName = JWTAlgorithmNameHS384; id firstHolder = [JWTAlgorithmHSFamilyDataHolder new].algorithmName(algorithmName).secret(firstSecret); // lets create chain JWTAlgorithmDataHolderChain *chain = [JWTAlgorithmDataHolderChain chainWithHolder:firstHolder]; // and lets populate chain with secrets. NSLog(@"chain has: %@", chain.debugDescription); JWTAlgorithmDataHolderChain *expandedChain = [chain chainByPopulatingAlgorithm:firstHolder.currentAlgorithm withManySecretData:manySecretsData]; // now we have expanded chain with many secrets and one algorithm. NSLog(@"expanded chain has: %@", expandedChain.debugDescription); ``` -------------------------------- ### Load PEM Keys from Files Source: https://cocoapods.org/pods/JWT Utility function to read the content of a PEM key file from the application bundle. Handles file not found errors and returns the file content as a string. ```objectivec - (NSString *)pemKeyStringFromFileWithName:(NSString *)string inBundle:(NSBundle *)bundle { NSURL *fileURL = [bundle URLForResource:name withExtension:@"pem"]; NSError *error = nil; NSString *fileContent = [NSString stringWithContentsOfURL:fileURL encoding:NSUTF8StringEncoding error:&error]; if (error) { NSLog(@"%@ error: %@", self.debugDescription, error); return nil; } } ``` -------------------------------- ### Encode and Decode JWT with RS256 Source: https://cocoapods.org/pods/JWT Illustrates JWT encoding and decoding using the RS256 algorithm, which requires a private key for encoding and a corresponding public key for decoding. Ensure the private key file and passphrase are correct. ```objectivec // Encode NSDictionary *payload = @{@"payload" : @"hidden_information"}; NSString *algorithmName = @"RS256"; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"secret_key" ofType:@"p12"]; NSData *privateKeySecretData = [NSData dataWithContentsOfFile:filePath]; NSString *passphraseForPrivateKey = @"secret"; JWTBuilder *builder = [JWTBuilder encodePayload:payload].secretData(privateKeySecretData).privateKeyCertificatePassphrase(passphraseForPrivateKey).algorithmName(algorithmName); NSString *token = builder.encode; // check error if (builder.jwtError == nil) { // handle result } else { // error occurred. } // Decode // Suppose, that you get token from previous example. You need a valid public key for a private key in previous example. // Private key stored in @"secret_key.p12". So, you need public key for that private key. NSString *publicKey = @"..."; // load public key. Or use it as raw string. algorithmName = @"RS256"; JWTBuilder *decodeBuilder = [JWTBuilder decodeMessage:token].secret(publicKey).algorithmName(algorithmName); NSDictionary *envelopedPayload = decodeBuilder.decode; // check error if (decodeBuilder.jwtError == nil) { // handle result } else { // error occurred. } ``` -------------------------------- ### Encode and Decode JWT with HS384 Source: https://cocoapods.org/pods/JWT Demonstrates encoding claims into a JWT and then decoding it using the HS384 algorithm. Ensure the secret and algorithm name match for successful decoding. ```objectivec // suppose, that you create ClaimsSet JWTClaimsSet *claimsSet = [[JWTClaimsSet alloc] init]; // fill it claimsSet.issuer = @"Facebook"; claimsSet.subject = @"Token"; claimsSet.audience = @"http://yourkarma.com"; // encode it NSString *secret = @"secret"; NSString *algorithmName = @"HS384"; NSDictionary *headers = @{@"custom":@"value"}; id algorithm = [JWTAlgorithmFactory algorithmByName:algorithmName]; JWTBuilder *encodeBuilder = [JWT encodeClaimsSet:claimsSet]; NSString *encodedResult = encodeBuilder.secret(secret).algorithm(algorithm).headers(headers).encode; if (encodeBuilder.jwtError == nil) { // handle encoded result NSLog(@"encoded result: %@", encodedResult); } else { // handle error NSLog(@"encode failed, error: %@", encodeBuilder.jwtError); } // decode it // you can set any property that you want, all properties are optional JWTClaimsSet *trustedClaimsSet = [claimsSet copy]; // decode forced ? try YES BOOL decodeForced = NO; NSNumber *options = @(decodeForced); NSString *yourJwt = encodedResult; // from previous example NSString *yourSecret = secret; // from previous example NSString *yourAlgorithm = algorithmName; // from previous example JWTBuilder *decodeBuilder = [JWT decodeMessage:yourJwt]; NSDictionary *decodedResult = decodeBuilder.message(yourJwt).secret(yourSecret).algorithmName(yourAlgorithm).claimsSet(trustedClaimsSet).options(options).decode; if (decodeBuilder.jwtError == nil) { // handle decoded result NSLog(@"decoded result: %@", decodedResult); } else { // handle error NSLog(@"decode failed, error: %@", decodeBuilder.jwtError); } ``` -------------------------------- ### Encode and Decode JWT with JWTBuilder Source: https://cocoapods.org/pods/JWT Demonstrates the modern fluent style for encoding and decoding JWTs using JWTBuilder. Use this for new development, replacing the old plain style. ```objc NSDictionary *payload = @{@"foo" : @"bar"}; NSString *secret = @"secret"; id algorithm = [JWTAlgorithmFactory algorithmByName:@"HS256"]; // Deprecated [JWT encodePayload:payload withSecret:secret algorithm:algorithm]; // Modern [JWTBuilder encodePayload:payload].secret(secret).algorithm(algorithm).encode; ``` -------------------------------- ### Sign and Verify JWT with RSA PEM Keys Source: https://cocoapods.org/pods/JWT Sign a JWT payload using a private RSA key in PEM format and verify it using the corresponding public RSA key. Requires specifying the algorithm and passphrase for the private key. Handles both signing and verification success and error cases. ```objectivec // Sign and verify - (void)signAndVerifyWithPrivateKeyPemString:(NSString *)privateKey publicKeyPemString:(NSString *)publicKey privateKeyPassphrase:(NSString *)passphrase { NSString *algorithmName = @"RS256"; id signDataHolder = [JWTAlgorithmRSFamilyDataHolder new].keyExtractorType([JWTCryptoKeyExtractor privateKeyWithPEMBase64].type).privateKeyCertificatePassphrase(passphrase).algorithmName(algorithmName).secret(privateKey); id verifyDataHolder = [JWTAlgorithmRSFamilyDataHolder new].keyExtractorType([JWTCryptoKeyExtractor publicKeyWithPEMBase64].type).algorithmName(algorithmName).secret(publicKey); // sign NSDictionary *payloadDictionary = @{@"hello": @"world"}; JWTCodingBuilder *signBuilder = [JWTEncodingBuilder encodePayload:payloadDictionary].addHolder(signDataHolder); JWTCodingResultType *signResult = signBuilder.result; NSString *token = nil; if (signResult.successResult) { // success NSLog(@"%@ success: %@", self.debugDescription, signResult.successResult.encoded); token = signResult.successResult.encoded; } else { // error NSLog(@"%@ error: %@", self.debugDescription, signResult.errorResult.error); } // verify if (token == nil) { NSLog(@"something wrong"); } JWTCodingBuilder *verifyBuilder = [JWTDecodingBuilder decodeMessage:token].addHolder(verifyDataHolder); JWTCodingResultType *verifyResult = verifyBuilder.result; if (verifyResult.successResult) { // success NSLog(@"%@ success: %@", self.debugDescription, verifyResult.successResult.payload); token = verifyResult.successResult.encoded; } else { // error NSLog(@"%@ error: %@", self.debugDescription, verifyResult.errorResult.error); } } ``` -------------------------------- ### Decode JWT with Algorithm Chain Source: https://cocoapods.org/pods/JWT Demonstrates decoding a JWT using an algorithm data holder chain. This is useful when the exact algorithm or secret is unknown. ```objective-c // create token NSString *token = @"..."; // possible that algorithm could return error. // you could try use algorithm and data chain. NSString *firstSecret = @"first"; NSString *firstAlgorithmName = JWTAlgorithmNameHS384; id firstHolder = [JWTAlgorithmHSFamilyDataHolder new].algorithmName(firstAlgorithmName).secret(firstSecret); id errorHolder = [JWTAlgorithmNoneDataHolder new]; // chain together. JWTAlgorithmDataHolderChain *chain = [[JWTAlgorithmDataHolderChain alloc] initWithHolders:@[firstHolder, errorHolder]]; // or add them in builder [JWTDecodingBuilder decodeMessage:token].addHolder(firstHolder).addHolder(errorHolder); // or add them as chain [JWTDecodingBuilder decodeMessage:token].chain(chain); ``` -------------------------------- ### Encode/Decode JWT with NSData Secret Source: https://cocoapods.org/pods/JWT Shows how to use NSData for the secret key during JWT encoding and decoding. Note that for decoding, the algorithm name must be explicitly specified. ```objectivec //Encode NSData *secretData = ""; NSString *algorithmName = @"HS384"; NSDictionary *headers = @{@"custom":@"value"}; id algorithm = [JWTAlgorithmFactory algorithmByName:algorithmName]; JWTBuilder *encodeBuilder = [JWT encodeClaimsSet:claimsSet]; NSString *encodedResult = encodeBuilder.secretData(secretData).algorithm(algorithm).headers(headers).encode; //Decode NSString *jwtToken = @"header.payload.signature"; NSData *secretData = "" NSString *algorithmName = @"HS256"; //Must specify an algorithm to use NSDictionary *payload = [JWTBuilder decodeMessage:jwtToken].secretData(secretData).algorithmName(algorithmName).decode; ``` -------------------------------- ### Decode JWT with Algorithm Whitelist Source: https://cocoapods.org/pods/JWT Decode a JWT by specifying a whitelist of allowed algorithms. This is useful when the algorithm is not known beforehand or when restricting decoding to specific algorithms. Handles potential decoding errors. ```objectivec NSString *jwtResultOrError = /*...*/; NSString *secret = @"secret"; JWTBuilder *builder = [JWT decodeMessage:jwtResultOrError].secret(@"secret").whitelist(@[@"HS256", @"none"]); NSDictionary *decoded = builder.decode; if (builder.jwtError) { // oh! } else { NSDictionary *payload = decoded[@"payload"]; NSDictionary *header = decoded[@"header"]; NSArray *tries = decoded[@"tries"]; // will be evolded into something appropriate later. } ``` -------------------------------- ### Decode JWT with Algorithm Whitelist Source: https://cocoapods.org/pods/JWT Decode a JWT while enforcing a whitelist of allowed algorithms. Providing an empty array for whitelist will result in nil, while a populated array will allow decoding if the algorithm matches. ```objc NSArray *whitelist = @[@"HS256", @"HS512"]; NSString *jwtToken = @"header.payload.signature"; NSString *secret = @"secret"; NSString *algorithmName = @"HS256"; //Returns nil NSDictionary *payload = [JWTBuilder decodeMessage:jwtToken].secret(secret).algorithmName(algorithmName).whitelist(@[]).decode; //Returns the decoded payload NSDictionary *payload = [JWTBuilder decodeMessage:jwtToken].secret(secret).algorithmName(algorithmName).whitelist(whitelist).decode; ``` -------------------------------- ### Decode Message with Whitelist Source: https://cocoapods.org/pods/JWT Decode a JWT, enforcing a whitelist of allowed algorithm names. ```APIDOC ## Decode Message with Whitelist ### Description Decode a JWT while enforcing a whitelist of allowed algorithm names. If the JWT's algorithm is not in the whitelist, decoding will fail. ### Method GET (conceptual, as this is an SDK method) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (parameters are passed as method arguments) ### Request Example ```objective-c NSArray *whitelist = @[@"HS256", @"HS512"]; NSString *jwtToken = @"header.payload.signature"; NSString *secret = @"secret"; NSString *algorithmName = @"HS256"; // Returns nil if algorithm is not in whitelist or other decoding errors occur NSDictionary *payload = [JWTBuilder decodeMessage:jwtToken].secret(secret).algorithmName(algorithmName).whitelist(whitelist).decode; ``` ### Response #### Success Response (200) - **payload** (NSDictionary) - The decoded payload of the JWT if the algorithm is whitelisted and decoding is successful. Returns nil otherwise. #### Response Example ```json { "payload": { "foo": "bar" } } ``` ``` -------------------------------- ### Encode JWT with Claims Set Source: https://cocoapods.org/pods/JWT Encode a JWT using a predefined JWTClaimsSet object. All properties within JWTClaimsSet are optional. ```objc JWTClaimsSet *claimsSet = [[JWTClaimsSet alloc] init]; claimsSet.issuer = @"Facebook"; claimsSet.subject = @"Token"; claimsSet.audience = @"http://yourkarma.com"; claimsSet.expirationDate = [NSDate distantFuture]; claimsSet.notBeforeDate = [NSDate distantPast]; claimsSet.issuedAt = [NSDate date]; claimsSet.identifier = @"thisisunique"; claimsSet.type = @"test"; NSString *secret = @"secret"; id algorithm = [JWTAlgorithmFactory algorithmByName:@"HS256"]; [JWTBuilder encodeClaimsSet:claimsSet].secret(secret).algorithm(algorithm).encode; ``` -------------------------------- ### Decode JWT with Claim Verification Source: https://cocoapods.org/pods/JWT Decode a JWT while verifying specific claims against a trusted claims set. Check the `jwtError` property of the builder to handle potential decoding or verification failures. ```objc // Trusted Claims Set JWTClaimsSet *trustedClaimsSet = [[JWTClaimsSet alloc] init]; trustedClaimsSet.issuer = @"Facebook"; trustedClaimsSet.subject = @"Token"; trustedClaimsSet.audience = @"http://yourkarma.com"; trustedClaimsSet.expirationDate = [NSDate date]; trustedClaimsSet.notBeforeDate = [NSDate date]; trustedClaimsSet.issuedAt = [NSDate date]; trustedClaimsSet.identifier = @"thisisunique"; trustedClaimsSet.type = @"test"; NSString *message = @"encodedJwt"; NSString *secret = @"secret"; NSString *algorithmName = @"chosenAlgorithm" JWTBuilder *builder = [JWTBuilder decodeMessage:jwt].secret(secret).algorithmName(algorithmName).claimsSet(trustedClaimsSet); NSDictionary *payload = builder.decode; if (builder.jwtError == nil) { // do your work here } else { // handle error } ``` -------------------------------- ### Encode Claims Set Source: https://cocoapods.org/pods/JWT Encode a JWTClaimsSet object into a JWT. ```APIDOC ## Encode Claims Set ### Description Encode a JWTClaimsSet object into a JWT, allowing for the use of reserved claim names. ### Method POST (conceptual, as this is an SDK method) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (parameters are passed as method arguments) ### Request Example ```objective-c JWTClaimsSet *claimsSet = [[JWTClaimsSet alloc] init]; claimsSet.issuer = @"Facebook"; claimsSet.subject = @"Token"; claimsSet.audience = @"http://yourkarma.com"; claimsSet.expirationDate = [NSDate distantFuture]; claimsSet.notBeforeDate = [NSDate distantPast]; claimsSet.issuedAt = [NSDate date]; claimsSet.identifier = @"thisisunique"; claimsSet.type = @"test"; NSString *secret = @"secret"; id algorithm = [JWTAlgorithmFactory algorithmByName:@"HS256"]; [JWTBuilder encodeClaimsSet:claimsSet].secret(secret).algorithm(algorithm).encode; ``` ### Response #### Success Response (200) - **encodedJWT** (string) - The resulting JWT string. #### Response Example ```json { "encodedJWT": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJGYWNlYm9vayIsInN1YiI6IlRva2VuIiwiYXVkIjoiSFRUUDovL3lvdXJrYXJtYS5jb20iLCJleHAiOjQxMDI0NDQ4MDAsIm5iZiI6LTEsImlhdCI6MTY3ODg4NjQwMCwianRkIjoidGhpc2lzYuniqueSIsInR5cCI6InRlc3QifQ.signature" } ``` ``` -------------------------------- ### Decode JWT Source: https://cocoapods.org/pods/JWT Decode a JWT token by providing the token string, secret, and algorithm name. The algorithm name is mandatory for decoding. ```objc NSString *jwtToken = @"header.payload.signature"; NSString *secret = @"secret"; NSString *algorithmName = @"HS256"; //Must specify an algorithm to use NSDictionary *payload = [JWTBuilder decodeMessage:jwtToken].secret(secret).algorithmName(algorithmName).decode; ``` -------------------------------- ### Decode Message Source: https://cocoapods.org/pods/JWT Decode a JWT string into a payload dictionary. ```APIDOC ## Decode Message ### Description Decode a JWT string into its payload dictionary, requiring a secret and algorithm name. ### Method GET (conceptual, as this is an SDK method) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (parameters are passed as method arguments) ### Request Example ```objective-c NSString *jwtToken = @"header.payload.signature"; NSString *secret = @"secret"; NSString *algorithmName = @"HS256"; //Must specify an algorithm to use NSDictionary *payload = [JWTBuilder decodeMessage:jwtToken].secret(secret).algorithmName(algorithmName).decode; ``` ### Response #### Success Response (200) - **payload** (NSDictionary) - The decoded payload of the JWT. #### Response Example ```json { "payload": { "foo": "bar" } } ``` ``` -------------------------------- ### Encode and Decode JWT ClaimsSet Source: https://cocoapods.org/pods/JWT Encode a JWT claims set with custom headers and a symmetric secret, then decode it. Ensure the secret and algorithm match for successful operations. Handles both success and error cases. ```objectivec JWTClaimsSet *claimsSet = [[JWTClaimsSet alloc] init]; // fill it claimsSet.issuer = @"Facebook"; claimsSet.subject = @"Token"; claimsSet.audience = @"https://jwt.io"; // encode it NSString *secret = @"secret"; NSString *algorithmName = @"HS384"; NSDictionary *headers = @{@"custom":@"value"}; idholder = [JWTAlgorithmHSFamilyDataHolder new].algorithmName(algorithmName).secret(secret); JWTCodingResultType *result = [JWTEncodingBuilder encodeClaimsSet:claimsSet].headers(headers).addHolder(holder).result; NSString *encodedToken = result.successResult.encoded; if (result.successResult) { // handle encoded result NSLog(@"encoded result: %@", result.successResult.encoded); } else { // handle error NSLog(@"encode failed, error: %@", result.errorResult.error); } // decode it // you can set any property that you want, all properties are optional JWTClaimsSet *trustedClaimsSet = [claimsSet copy]; NSNumber *options = @(JWTCodingDecodingOptionsNone); NSString *yourJwt = encodedToken; // from previous example JWTCodingResultType *decodedResult = [JWTDecodingBuilder decodeMessage:yourJwt].claimsSet(claimsSet).addHolder(holder).options(options).and.result; if (decodedResult.successResult) { // handle decoded result NSLog(@"decoded result: %@", decodedResult.successResult.headerAndPayloadDictionary); NSLog(@"headers: %@", decodedResult.successResult.headers); NSLog(@"payload: %@", decodedResult.successResult.payload); } else { // handle error NSLog(@"decode failed, error: %@", decodedResult.errorResult.error); } ``` -------------------------------- ### Decode Message with Claims Set Validation Source: https://cocoapods.org/pods/JWT Decode a JWT and validate its claims against a trusted Claims Set. ```APIDOC ## Decode Message with Claims Set Validation ### Description Decode a JWT and validate its claims against a provided trusted Claims Set. The builder will contain an error if validation fails. ### Method GET (conceptual, as this is an SDK method) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (parameters are passed as method arguments) ### Request Example ```objective-c // Trusted Claims Set JWTClaimsSet *trustedClaimsSet = [[JWTClaimsSet alloc] init]; trustedClaimsSet.issuer = @"Facebook"; trustedClaimsSet.subject = @"Token"; trustedClaimsSet.audience = @"http://yourkarma.com"; trustedClaimsSet.expirationDate = [NSDate date]; trustedClaimsSet.notBeforeDate = [NSDate date]; trustedClaimsSet.issuedAt = [NSDate date]; trustedClaimsSet.identifier = @"thisisunique"; trustedClaimsSet.type = @"test"; NSString *message = @"encodedJwt"; NSString *secret = @"secret"; NSString *algorithmName = @"chosenAlgorithm" JWTBuilder *builder = [JWTBuilder decodeMessage:message].secret(secret).algorithmName(algorithmName).claimsSet(trustedClaimsSet); NSDictionary *payload = builder.decode; if (builder.jwtError == nil) { // do your work here } else { // handle error } ``` ### Response #### Success Response (200) - **payload** (NSDictionary) - The decoded payload of the JWT if validation is successful. - **jwtError** (NSError) - An error object if validation fails, otherwise nil. #### Response Example ```json { "payload": { "iss": "Facebook", "sub": "Token", "aud": "http://yourkarma.com", "exp": 1678886400, "nbf": 1678886400, "iat": 1678886400, "jti": "thisisunique", "typ": "test" }, "jwtError": null } ``` ``` -------------------------------- ### Encode JWT with Payload Source: https://cocoapods.org/pods/JWT Encode an arbitrary payload into a JWT using the JWTBuilder fluent interface. Ensure you provide the payload, secret, and algorithm. ```objc NSDictionary *payload = @{@"foo" : @"bar"}; NSString *secret = @"secret"; id algorithm = [JWTAlgorithmFactory algorithmByName:@"HS256"]; [JWTBuilder encodePayload:payload].secret(secret).algorithm(algorithm).encode; ``` -------------------------------- ### Encode Payload Source: https://cocoapods.org/pods/JWT Encode an arbitrary payload into a JWT using the JWTBuilder. ```APIDOC ## Encode Payload ### Description Encode an arbitrary payload into a JWT using the JWTBuilder. ### Method POST (conceptual, as this is an SDK method) ### Endpoint N/A (SDK Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (parameters are passed as method arguments) ### Request Example ```objective-c NSDictionary *payload = @{@"foo" : @"bar"}; NSString *secret = @"secret"; id algorithm = [JWTAlgorithmFactory algorithmByName:@"HS256"]; [JWTBuilder encodePayload:payload].secret(secret).algorithm(algorithm).encode; ``` ### Response #### Success Response (200) - **encodedJWT** (string) - The resulting JWT string. #### Response Example ```json { "encodedJWT": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.signature" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.