Skip to content

JWT Auth - Anyone using it for recipes? #297

Answered by dargs
dargs asked this question in Q&A
Discussion options

You must be logged in to vote

Got it working, after trying lots of different things !

from org.joda.time import DateTime
from org.joda.time import DateTimeZone
from io.jsonwebtoken import Jwts
from io.jsonwebtoken import SignatureAlgorithm
from org.apache.commons.codec.binary import Base64
from org.apache.commons.codec.binary import Hex

def get_json_web_token(apiUserKey, apiUserId, apiUserSecret):
  console.log('[get_json_web_token] called')
  aBase64 = Base64()
  encodedHexB64 = aBase64.encodeBase64(apiUserSecret)  # array.array('b', [...])  
  secretkey = encodedHexB64.tostring()  # No good with str(encodedHexB64)

  return Jwts.builder() \
    .setHeaderParam("alg", "RS256").setHeaderParam("typ", "JWT") \
    .set…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@dargs
Comment options

dargs Apr 16, 2023
Collaborator Author

@dargs
Comment options

dargs Apr 16, 2023
Collaborator Author

@morimoriysmoon
Comment options

Comment options

dargs
Mar 23, 2023
Collaborator Author

You must be logged in to vote
1 reply
@justparking
Comment options

Comment options

dargs
Apr 26, 2023
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by dargs
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