Allow use of an API key instead of the deprecated per-instance login

PopIt is migrating from having a single username / password for each
instance to having site-wide logins for the web interface and API
keys for programmatic use.  This commit introduces support for API
keys, without breaking old code that uses the legacy per-instance login
system.