Guard against array index out of bounds when building auth header

Pretty self-explanatory. Harmless, too.