Token Generate Method

Caché

Hi community ,

i develop my LogUser Method on my rest API , the scenario is as follow :

when user enter his login & password , i check first in my table if he exists (this stape is done), now i want know how generate acces token from authorization server , i've as idea to call the  "%OAuth2.Server.Generate" which is implemented on the configuration party (we find the correspondint attached screenshot ), but i don't know if i'm sure , we find here the developped method:

ClassMethod LogUser(profile) As %Status
{
 set user ={}.%FromJSON(profile)
 set login=user.username
 set password=user.password
  // now we check on the security.users
   set ID=Replace(login,"@","^")
   
   //basculer vers le name space %sys
   zn "%sys"
 
  set x=$System.Security.Login(ID,password)
  if x=0 { write "unknown user"}
 
  else
    //  get role from resources BWX
  {
    set role=$roles
    set a=[],sep=","
    for i=1:1:$length($roles,sep) { do a.%Push($piece($roles,sep,i))}
    w a.%ToJSON()
    
    //generate acces token 
 
     
 }                                               
   
   quit $$$OK
 
  }

thank you for help.

  • + 1
  • 0
  • 248
  • 0
  • 0