Created
December 11, 2014 13:55
-
-
Save mishok13/8952f03ca99a67247896 to your computer and use it in GitHub Desktop.
Google is happy to make sure you spend an hour figuring out why your base64 encoding is not working correctly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; From their doc at https://developers.google.com/accounts/docs/OAuth2ServiceAccount#authorizingrequests | |
;; You have to base64 a few parts of the request, including a so called "claim set" | |
;; This is what they claim to encode: | |
(def expected-claim "{\"iss\":\"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com\",\"scope\":\"https://www.googleapis.com/auth/prediction\",\"aud\":\"https://www.googleapis.com/oauth2/v3/token\",\"exp\":1328554385,\"iat\":1328550785}") | |
;; And this is what they put as "base64" encoded string: | |
(def expected-encoded "eyJpc3MiOiI3NjEzMjY3OTgwNjktcjVtbGpsbG4xcmQ0bHJiaGc3NWVmZ2lncDM2bTc4ajVAZGV2ZWxvcGVyLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJzY29wZSI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL2F1dGgvcHJlZGljdGlvbiIsImF1ZCI6Imh0dHBzOi8vYWNjb3VudHMuZ29vZ2xlLmNvbS9vL29hdXRoMi90b2tlbiIsImV4cCI6MTMyODU1NDM4NSwiaWF0IjoxMzI4NTUwNzg1fQ") | |
;; Well, decode it and you get | |
(println (base64/decode expected-encoded)) | |
;; "{\"iss\":\"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com\",\"scope\":\"https://www.googleapis.com/auth/prediction\",\"aud\":\"https://accounts.google.com/o/oauth2/token\",\"exp\":1328554385,\"iat\":1328550785}" | |
;; Note that "aud" key and the associated URL. FFS. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment