Modified version from CRMKit PHPTOCRMOnline to work with office 365 auth