Search the Community
Showing results for tags 'byte'.
-
So I have been reading on how to use OAuth2 Service accounts(https://developers.google.com/identity/protocols/OAuth2ServiceAccount) and ran into an issue with autoit I can not solve. To keep this short to communicate to the Google API I need to use a JSON Web signature containing {Base64url encoded header}.{Base64url encoded claim set}. The Header and claim set work fine but I do not know how to convert them to a byte array using autoit. I have looked around on the forums and website but have not found anything that seems to work. Here is my code. #include-once #include <Array.au3> #include <Constants.au3> #include <Debug.au3> #include <File.au3> #include "Json.au3" #include <Process.au3> #include <ProgressConstants.au3> #include <String.au3> #include <WindowsConstants.au3> #include "WinHttp.au3" #include <UnixTime.au3> #include <StringConstants.au3> Global $UnixTime = _TimeGetStamp() $sJWTheader = '{"alg":"RS256","typ":"JWT"}' $sJWTclaimset = '{"iss":"Removed@forprivacy.com","scope":"https://www.googleapis.com/auth/spreadsheets","aud":"https://www.googleapis.com/oauth2/v4/token","exp":' & $UnixTime + 3600 & ',"iat":' & $UnixTime & '}' Local $taiData = DllStructCreate("BYTE[256]") Local $sText = _base64($sJWTheader)&'.'&_base64($sJWTclaimset) DllStructSetData($taiData, 1, StringToBinary($sText, 4)) Local $bvResult = DllStructGetData($taiData, 1) $sJWTSigature = $bvResult $sJWT = _base64($sJWTheader)&'.'&_base64($sJWTclaimset)&'.'&_base64($sJWTSigature) $POSTHeader = "Content-Type: application/x-www-form-urlencoded" $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "https://www.googleapis.com/") $sRead = _WinHttpSimpleSSLRequest($hConnect, "POST", "oauth2/v4/token", Default, "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=" & $sJWT) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ConsoleWrite($sRead & @LF) The whole bytes thing is beyond with what I know about auotit. I can't tell what I need to fix.
-
Hi, I don't understand how the size of the structure works. I know that an int has a size of 4 bytes, if I get the size of the struct then I have 4 bytes; a byte has as size of 1 byte, if I get the size of the struct then I have 1 byte. Until here everything seems fine, unless I make a structure with the two elements, the size is 8 bytes; 4+1=5 and not 8. Here is the example : #include <Constants.au3> Local Const $tagSTRUCT1 = "struct;int var1;endstruct" Local $tSTRUCT1 = DllStructCreate($tagSTRUCT1) MsgBox($MB_SYSTEMMODAL, "", "Struct1 Size: " & DllStructGetSize($tSTRUCT1)) Local Const $tagSTRUCT2 = "struct;byte var2;endstruct" Local $tSTRUCT2 = DllStructCreate($tagSTRUCT2) MsgBox($MB_SYSTEMMODAL, "", "Struct2 Size: " & DllStructGetSize($tSTRUCT2)) Local Const $tagSTRUCT3 = "struct;int var1;byte var2;endstruct" Local $tSTRUCT3 = DllStructCreate($tagSTRUCT3) MsgBox($MB_SYSTEMMODAL, "", "Struct3 Size: " & DllStructGetSize($tSTRUCT3)) Thanks for anyhelp Br, FireFox.
- 2 replies
-
- DllStructGetSize
- byte
-
(and 2 more)
Tagged with: