Perhaps something like this (untested):
PHP Code:
Function Authenticate
#Call to REST API for user authentication
nsJSON::Set /file "c:\temp\<some file>"
IfSilent skipGuiStart
ShowWindow $WAITMSG ${SW_SHOW}
${NSD_SetText} $WAITMSG "User authentication in progress...."
AnimGif:lay /NOUNLOAD /HALIGN=83 /VALIGN=73 $PLUGINSDIR\a.gif
skipGuiStart:
inetc:ost "grant_type=password&username=$UserNameText&password=$UserPwdText" /SILENT "<URL>" "c:\temp\<some file>" /END
NsisCrypt::Base64Encode $UserNameText
Pop $1
#MessageBox MB_OK $1
nsJSON::Set /file "c:\temp\<some file>" /END
nsJSON::Get /exists "access_token" /END
Pop $0
${If} $0 == "yes"
nsJSON::Get "access_token" /END
Pop $TOKEN
#MessageBox MB_OK $TOKEN
StrCpy $isValidUser "true"
#Call to REST API for getting the institution details
IfSilent skipGuiSetText
${NSD_SetText} $WAITMSG "Getting Institution details...."
skipGuiSetText:
inetc::get /SILENT "<URL>" "c:\temp\<some file>" /END
nsJSON::Set /file "c:\temp\<some file>" /END
nsJSON::Get /count /END
Pop $INSTITUTIONCOUNT
${Else}
StrCpy $isValidUser "false"
${EndIf}
#delete "c:\temp\<some file>"
IfSilent skipGuiEnd
ShowWindow $WAITMSG ${SW_HIDE}
AnimGif::stop
skipGuiEnd:
FunctionEnd
; First section
Section -SilentAuth
IfSilent 0 +2
Call Authenticate
SectionEnd
; Other sections follow