Problem in creating jwt token creation using RS256 in ios
I am trying to create a jwt token for using in box.com authentication (Oauth2 and JWT) in an ios mobile app. Our requirement is to access the box apis without login screen in the mobile app using REST APIs without Box SDK. As per box.com documentation I have created private/public keypair files using box dashboard. Now I have to create a jwt token and sign it using RS256 algorithm based on the private key file content. I am trying to use an objective c library 'JWT' (https://github.com/yourkarma/JWT) for generating a signed jwt token but I don't understand cleary how to use the ios JWT API for box to generate singed JWT Token using the private key file content.
When I am using the following code I am getting errors like "Error Domain=io.jwt Code=-92 "It seems that signing output corrupted. Make sure signing worked (e.g. we may have issues extracting the key from the PKCS12 bundle if passphrase is incorrect)."
JWTBuilder *builder = [JWTBuilder encodePayload:payload].headers(headers).secret(privateKeySecretData).privateKeyCertificatePassphrase(passphraseForPrivateKey).algorithmName(algorithmName);
NSString *token = builder.encode;
In the above code privateKeySecretData is the private key content as string -----BEGIN RSA PRIVATE KEY----- Data -----END RSA PRIVATE KEY-----
Can anyone please help me regarding this.
Please sign in to leave a comment.
Comments
1 comment