You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe that the bug is due to the buffer being read before the encoder is closed. Per the docs:
when finished writing, the caller must Close the returned encoder to flush any partially written blocks.
If we return the buffer as a string (at function end) before the encoder is closed (via defer) we'll be returning only part of the base64 encoded string. In testing, this repeated led to AQ== being left off of the returned base64 encoded string. When I explicitly closed the encoder before returning the string the result was valid every time.
@sqs
Thank you for creating this package! It was very helpful in understanding the XOAuth2 string format is handled.
While using this package, I noticed that I was getting different results from the
XOAuth2String
function than I did a PowerShell implementation here:After some trial & error, I realized that it was due to these lines:
go-xoauth2/xoauth2.go
Lines 25 to 26 in 0911dad
I believe that the bug is due to the buffer being read before the encoder is closed. Per the docs:
If we return the buffer as a string (at function end) before the encoder is closed (via defer) we'll be returning only part of the base64 encoded string. In testing, this repeated led to
AQ==
being left off of the returned base64 encoded string. When I explicitly closed the encoder before returning the string the result was valid every time.refs https://github.com/DanijelkMSFT/ThisandThat/blob/bc7649953761cd2d1b462172df7df6be9bb9eb9b/Get-IMAPAccessToken.ps1
The text was updated successfully, but these errors were encountered: