Merge pull request #2 from pkit/auth

fixed some memory problems
Fix compile errors
Fix building token header entry
Auth if sending for the firsst time
Fix dangerous buffer write
Merge pull request #3 from rampage644/master

Fixes, auth on first time
Removed unnecessary map entries
Retrieve tenant id from auth as well
Merge pull request #4 from rampage644/auth

Auth