Don't set token header when token is `undefined`.

Check the type of the `token` property since using `in` will return `true` when the property is set but `undefined`.