Skip to content

Commit

Permalink
Use base64_url_decode for decoding signed request JSON.
Browse files Browse the repository at this point in the history
https://developers.facebook.com/docs/authentication/signed_request/ states that the JSON part of the signed request is base64url encoded.

Without this fix, decoding signed requests containing _ or - characters leads to garbled strings and JSON parsing fails subsequently.
  • Loading branch information
noniq authored and mmangino committed Sep 6, 2012
1 parent 6326e7a commit 23dca89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/facebooker2/rails/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def generate_signature(hash,secret)
def fb_signed_request_json(encoded)
chars_to_add = 4-(encoded.size % 4)
encoded += ("=" * chars_to_add)
Base64.decode64(encoded)
base64_url_decode(encoded)
end

def facebook_params
Expand Down

0 comments on commit 23dca89

Please sign in to comment.