JSONWebToken.swift icon indicating copy to clipboard operation
JSONWebToken.swift copied to clipboard

Get Raw ClaimSet Data

Open jupl opened this issue 8 years ago • 8 comments

I'm using let payload: Payload = try JWT.decode(...) to get the dictionary data to pass off to a 3rd party library. I'm getting a deprecated notice so I try let claimSet: ClaimSet = JWT.decode(...); claimSet.claims but get the error 'claims' is inaccessible due to 'internal' protection level.

EDIT: Forgot to mention I'm using Carthage.

jupl avatar Apr 27 '17 18:04 jupl

I also need this, or the best possible way to convert to an NSDictionary for an Objective-C implementation.

benguild avatar May 29 '17 06:05 benguild

How can we use this in Objective-C any Idea. I have used cocoapods file for Swift, but calling JWT file in Objective-C not working.

kashiftriffort avatar Jun 14 '17 10:06 kashiftriffort

@kashiftriffort You need to wrap the methods you need in a bridge file. However, this issue is specifically surrounding the fact that the code was changed recently and it's now throwing a warning that a certain method that helped enable this is deprecated.

'decode(_:algorithms:verify:audience:issuer:)' is deprecated: use decode that returns a ClaimSet instead

benguild avatar Jun 14 '17 10:06 benguild

I don't think we need a bridge file for this, after Cocopods installed, I can directly called #import "JWT-Swift.h", into Objective-C file and option for bridging header is not provided in Objective-C target. If you give me any support that will be great help for me.

kashiftriffort avatar Jun 14 '17 10:06 kashiftriffort

I also need the data, as I have an API which returns a JWT body for certain responses, which I would like to feed to JSONDecoder. For now I've forked and make claims public, and I convert that back to JSON data before decoding.

jshier avatar Oct 24 '17 20:10 jshier

I don’t know what the status of this is but I still believe it is overly abstracted.

benguild avatar Oct 25 '17 03:10 benguild

I 've created a pull request that makes "claims" accessible for reading. See https://github.com/kylef/JSONWebToken.swift/pull/99

If you need a "fast solution" you can use my forked version pod 'JSONWebToken', :git => 'https://github.com/Wooder/JSONWebToken.swift.git' as temporary workaround.

Wooder avatar Jan 20 '18 11:01 Wooder

@Wooder [!] Unable to find a specification for 'JSONWebToken'.

dzpt avatar Dec 09 '18 16:12 dzpt