NetTalk Central

Author Topic: Example of using JWTs in a web service.....  (Read 728 times)

PaulMacFarlane

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Example of using JWTs in a web service.....
« on: November 01, 2024, 03:29:06 PM »
Moved this - posted in the wrong section....

I'm probably over thinking this.  I've seen the threads here about constructing JWTs for authentication use....

https://www.nettalkcentral.com/forum/index.php?topic=8902.msg36457#msg36457
https://www.nettalkcentral.com/forum/index.php?topic=8089.msg32855#msg32855

Using the example from Wiki:  https://en.wikipedia.org/wiki/JSON_Web_Token

net.SetValue('grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer')
net.SetValue('assertion',StringContainingtheWholeJWT)
net.Post(urlString)

And I'd get returned values in the page received method:
if Self.ThisPage.Length() > 0
  json.load(resultGroup,self.thispage.GetValuePtr(),self.thispage.Length())
  display()
End

where resultgroup will be....
ResultGroup     GROUP,PRE(result)
access_token    STRING(512)
token_type      STRING(16)
expires_in   long
                END


The service I'm trying to connect to (IRS) requires sending 2 JWTs (for 2 different roles) when connecting.

net.SetValue('grant_type','urn:ietf:params:oauth:grant-type:jwt-bearer')
net.SetValue('assertion',StringContainingtheWholeJWT)
net.SetValue('client_assertion_type','urn:ietf:params:oauth:client-assertion-type:jwt-bearer')
net.SetValue('client_assertion',StringContainingtheWholeJWT)
net.Post(urlString)

Am I thinking this correctly or way off base?  Anyone have an example?