Lorenzo Aiello
Lorenzo Aiello

Reputation: 439

Facebook signed_request Invalid

So I've been fiddling about with creating a Facebook Page App and am running into an obstacle.

The API Documentation (https://developers.facebook.com/docs/reference/login/signed-request/) indicates that it is a json encoded base64 encoded string, but I've found that more often then not it doesn't decode (PHP) properly.

Example String

[signed_request] => ccskn7MGtWvG9XXAU5F8nE61aFy-PP-2Jmvz35iwtOo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM4NjEyNTk5NCwicGFnZSI6eyJpZCI6IjM5ODYxMDQ0MDIxNDI2NiIsImxpa2VkIjpmYWxzZSwiYWRtaW4iOnRydWV9LCJ1c2VyIjp7ImNvdW50cnkiOiJ1cyIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fX0

I did find this other question (Invalid base64 in Facebook signed_request documentation example), but after trying to add padding, still not gibberish results.

Any help is appreciated.

Upvotes: 0

Views: 241

Answers (1)

C3roe
C3roe

Reputation: 96455

To parse the signed_request, first it must be split at the first dot . character, and then in the second part you have to replace the characters - and _ by + and / respectively – and after that base64-decode it.

As for your question, where this is documented – in the document that is linked right on top of the document that you mentioned, here: https://developers.facebook.com/docs/facebook-login/using-login-with-games/#parsingsr

Upvotes: 1

Related Questions