mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #227] Parameters converted to String #129
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#129
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kajensen on GitHub (May 10, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/227
I think you should just return the response NSData (or [String: AnyObject]) instead of casting json to a [String: String]. Unless there is a good reason for this?
This is an issue for instagram oauth where the response has user data in a dictionary.
@phimage commented on GitHub (May 10, 2016):
Could you give the lines of code?
maybe
if let jsonDico = responseJSON as? [String:AnyObject] {
responseParameters = jsonDico.map { (key, value) in (key, String(value)) }
}
the cast here is good, but then all object are converted to string...
Have you really an NSData, not an nsdictionary?
@kajensen commented on GitHub (May 11, 2016):
Yeah, thats the line i'm talking about. I changed it so parameters is a [String: AnyObject] dictionary in TokenSuccessHandler, and I return the responseJSON (line 190 in Oauth2.swift) instead of the casted parameters used to extract the credentials as strings.
@kajensen commented on GitHub (May 11, 2016):
The cast made it nearly impossible to translate it back to a dictionary so this was easier for me.
@phimage commented on GitHub (May 11, 2016):
are you able to respond to my question? is it NSData or NSDictionary?
its readable after converting it to string ?(ie is its a json string, its easy a create a dictionary from it)
@kajensen commented on GitHub (May 11, 2016):
its an nsdictionary. its readable as a string, but I tried a few different things and did not find it easy to create a dictionary from it.
@phimage commented on GitHub (May 11, 2016):
try this from stack over flow if its a json string, maybe not, just a dictionary string representation
(if not json, maybe I will add a way to choose how to cast to string)
func convertStringToDictionary(text: String) -> [String:AnyObject]? {
if let data = text.dataUsingEncoding(NSUTF8StringEncoding) {
do {
let json = try NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers) as? [String:AnyObject]
return json
} catch {
print("Something went wrong")
}
}
return nil
}
@kajensen commented on GitHub (May 11, 2016):
Yeah I tried that among other things. I guess I just don't understand the rationale for casting it to a string and then forcing a cast back if necessary?
@phimage commented on GitHub (May 11, 2016):
Unfortunately I can change method signature easily without impacting all people which use the library
You could PR anyway, and I will think about it and merge only into a main release