sqs / go-xoauth2 Goto Github PK
View Code? Open in Web Editor NEWGo library for generating XOAuth2 strings (for use in XOAUTH2 SASL auth schemes for IMAP/SMTP)
License: BSD 2-Clause "Simplified" License
Go library for generating XOAuth2 strings (for use in XOAUTH2 SASL auth schemes for IMAP/SMTP)
License: BSD 2-Clause "Simplified" License
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:
if ( $SharedMailbox ) {
$b="user=" + $SharedMailbox + "$([char]0x01)auth=Bearer " + $accessToken + "$([char]0x01)$([char]0x01)"
Write-Host "Accessing Sharedmailbox - $SharedMailbox - with Accesstoken of User $userName." -ForegroundColor DarkGreen
} else {
$b="user=" + $userName + "$([char]0x01)auth=Bearer " + $accessToken + "$([char]0x01)$([char]0x01)"
}
$Bytes = [System.Text.Encoding]::ASCII.GetBytes($b)
$POPIMAPLogin =[Convert]::ToBase64String($Bytes)
Write-Verbose "SASL XOAUTH2 login string $POPIMAPLogin"
After some trial & error, I realized that it was due to these lines:
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:
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.