Skip to content

using Berry with Google drive API #18758

Answered by s-hadinger
btsimonh asked this question in Q&A
Discussion options

You must be logged in to vote

It's working now with the latest commit in development branch.

import string
import crypto

# JWT requires base64url and not raw base64
# see https://base64.guru/standards/base64url
# input: string or bytes
def base64url(v)
  import string
  if type(v) == 'string'   v = bytes().fromstring(v) end
  var b64 = v.tob64()
  # remove trailing padding
  b64 = string.tr(b64, '=', '')
  b64 = string.tr(b64, '+', '-')
  b64 = string.tr(b64, '/', '_')
  return b64
end

# JWT header and claim
var header = '{"alg":"RS256","typ":"JWT"}'
var claim = '{"sub":"1234567890","name":"John Doe","admin":true,"iat":1516239022}'
var b64header = base64url(header)
var b64claim = base64url(claim)

assert(b64header == 

Replies: 4 comments 31 replies

Comment options

You must be logged in to vote
24 replies
@s-hadinger
Comment options

@btsimonh
Comment options

@s-hadinger
Comment options

@s-hadinger
Comment options

Answer selected by btsimonh
@btsimonh
Comment options

@s-hadinger
Comment options

@btsimonh
Comment options

@btsimonh
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@s-hadinger
Comment options

@btsimonh
Comment options

@s-hadinger
Comment options

@btsimonh
Comment options

@btsimonh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants