refactor authorization header generation