Unable to Login With Initial Account

Nextcloud version (eg, 12.0.2): 14.0.4
Operating system and version (eg, Ubuntu 17.04): Ubuntu 16.05.5 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.18
PHP version (eg, 7.1): 7.0.32-0ubuntu0.16.04.1

The issue you are facing:
After updating to the latest version of Nextcloud, I am unable to use the account which was initially set up for the server. It is, unfortunately, one that has a rather large shared folder and I need to increase the size to accommodate more files. I haven’t logged in to the account for a few months, so it is possible that this issue occurred during the last update or even one prior to it. Looking at my Nextcloud log, I’m wondering if the issue is because I have high ANSI characters in my password. It may just be belching on some of those. If that’s the case, is there any way to fix the PHP so that it will accept the password like it used to before?

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Attempt to log in to system from web browser using specified account
  2. Receive “Internal Server Error” message on web-based login screen

The output of your Nextcloud log in Admin > Logging:

Error | index | TypeError: base64_encode() expects parameter 1 to be string, null given | 2018-11-30T17:01:27-0600
0. /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php - line 242: base64_encode(null)
1. /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php - line 308: OC\Authentication\Token\PublicKeyTokenProvider->encryptPassword("*** sensiti ... *")
2. /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php - line 70: OC\Authentication\Token\PublicKeyTokenProvider->newToken("*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *")
3. /var/www/nextcloud/lib/private/Authentication/Token/Manager.php - line 69: OC\Authentication\Token\PublicKeyTokenProvider->generateToken("*** sensiti ... *")
4. /var/www/nextcloud/lib/private/User/Session.php - line 641: OC\Authentication\Token\Manager->generateToken("*** sensiti ... *")
5. /var/www/nextcloud/core/Controller/LoginController.php - line 322: OC\User\Session->createSessionToken("*** sensiti ... *")
6. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 166: OC\Core\Controller\LoginController->tryLogin("*** sensiti ... *")
7. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 99: OC\AppFramework\Http\Dispatcher->executeController(OC\Core\Cont ... {}, "tryLogin")
8. /var/www/nextcloud/lib/private/AppFramework/App.php - line 118: OC\AppFramework\Http\Dispatcher->dispatch(OC\Core\Cont ... {}, "tryLogin")
9. /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App::main("OC\\Core\\C ... r", "tryLogin", OC\AppFramew ... {}, { _route: "c ... "})
10. OC\AppFramework\Routing\RouteActionHandler->__invoke({ _route: "c ... "})
11. /var/www/nextcloud/lib/private/Route/Router.php - line 297: call_user_func(OC\AppFramew ... {}, { _route: "c ... "})
12. /var/www/nextcloud/lib/base.php - line 987: OC\Route\Router->match("/login")
13. /var/www/nextcloud/index.php - line 42: OC::handleRequest()

Error | index | TypeError: base64_encode() expects parameter 1 to be string, null given | 2018-11-30T16:55:32-0600
0. /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php - line 242: base64_encode("*** sensiti ... *")
1. /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php - line 308: OC\Authentication\Token\PublicKeyTokenProvider->encryptPassword("*** sensiti ... *")
2. /var/www/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php - line 70: OC\Authentication\Token\PublicKeyTokenProvider->newToken("*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *", "*** sensiti ... *")
3. /var/www/nextcloud/lib/private/Authentication/Token/Manager.php - line 69: OC\Authentication\Token\PublicKeyTokenProvider->generateToken("*** sensiti ... *")
4. /var/www/nextcloud/lib/private/User/Session.php - line 641: OC\Authentication\Token\Manager->generateToken("*** sensiti ... *")
5. /var/www/nextcloud/core/Controller/LoginController.php - line 322: OC\User\Session->createSessionToken("*** sensiti ... *")
6. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 166: OC\Core\Controller\LoginController->tryLogin("*** sensiti ... *")
7. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 99: OC\AppFramework\Http\Dispatcher->executeController(OC\Core\Cont ... {}, "tryLogin")
8. /var/www/nextcloud/lib/private/AppFramework/App.php - line 118: OC\AppFramework\Http\Dispatcher->dispatch(OC\Core\Cont ... {}, "tryLogin")
9. /var/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App::main("OC\\Core\\C ... r", "tryLogin", OC\AppFramew ... {}, { _route: "c ... "})
10. OC\AppFramework\Routing\RouteActionHandler->__invoke({ _route: "c ... "})
11. /var/www/nextcloud/lib/private/Route/Router.php - line 297: call_user_func(OC\AppFramew ... {}, { _route: "c ... "})
12. /var/www/nextcloud/lib/base.php - line 987: OC\Route\Router->match("/login")
13. /var/www/nextcloud/index.php - line 42: OC::handleRequest()

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => '[redacted]',
  'secret' => '[redacted]',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'nextcloud',
    2 => '192.168.[local].[address]',
    3 => 'cloud.domain.com',
  ),
  'datadirectory' => '/var/ncdata',
  'overwrite.cli.url' => 'https://cloud.domain.com/',
  'overwritehost' => 'cloud.domain.com',
  'overwriteprotocol' => 'https',
  'overwritecondaddr' => '192\\.168\\.[proxy]\\.[address]$',
  'trusted_proxies' =>
  array (
    0 => '192.168.[proxy].[address]',
  ),
  'forwarded_for_headers' =>
  array (
    0 => 'HTTP_X_FORWARDED_FOR',
  ),
  'allow_user_to_change_display_name' => false,
  'dbtype' => 'mysql',
  'version' => '14.0.4.2',
  'dbname' => '[redacted]',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '[redacted]',
  'dbpassword' => '[redacted]',
    'installed' => true,
  'instanceid' => '[redacted]',
  'maintenance' => false,
  'mail_smtpmode' => 'smtp',
  'log_rotate_size' => '1048576',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0,
    'dbindex' => 0,
    'password' => '[redacted]',
  ),
  'htaccess.RewriteBase' => '/',
  'loglevel' => '2',
  'log_type' => 'file',
  'logfile' => '/var/ncdata/nextcloud.log',
  'logtimezone' => 'America/Chicago',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_from_address' => '[username]',
  'mail_domain' => 'domain.com',
  'mail_smtphost' => '192.168.[proxy].[address]',
  'mail_domain' => 'domain.com',
  'mail_smtphost' => '192.168.[proxy].[address]',
  'mail_smtpport' => '[redacted]',
  'mail_smtpauthtype' => 'LOGIN',
);

The output of your Nextcloud log in /var/log/____:

{"reqId":"zbml4yvPMfiiSngl38cr","level":3,"time":"2018-11-30T16:55:32-06:00","remoteAddr":"192.168.[local].[address]","user":"SuperDuperUser","app":"index","method":"POST","url":"\/login","message":{"Exception":"TypeError","Message":"base64_encode() expects parameter 1 to be string, null given","Code":0,"Trace":[{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":242,"function":"base64_encode","args":["*** sensitive parameter replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":308,"function":"encryptPassword","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":70,"function":"newToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/Manager.php","line":69,"function":"generateToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/User\/Session.php","line":641,"function":"generateToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/core\/Controller\/LoginController.php","line":322,"function":"createSessionToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":166,"function":"tryLogin","class":"OC\\Core\\Controller\\LoginController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\LoginController"},"tryLogin"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/App.php","line":118,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\LoginController"},"tryLogin"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\LoginController","tryLogin",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.login.tryLogin"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"core.login.tryLogin"}]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"core.login.tryLogin"}]},{"file":"\/var\/www\/nextcloud\/lib\/base.php","line":987,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/login"]},{"file":"\/var\/www\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","Line":242,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36 OPR\/57.0.3098.76","version":"14.0.4.2"}
{"reqId":"0PKtZ8dEtdiipU9f9bEQ","level":3,"time":"2018-11-30T17:01:27-06:00","remoteAddr":"192.168.[local].[address]","user":"SuperDuperUser","app":"index","method":"POST","url":"\/login?redirect_url=\/apps\/apporder\/","message":{"Exception":"TypeError","Message":"base64_encode() expects parameter 1 to be string, null given","Code":0,"Trace":[{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":242,"function":"base64_encode","args":[null]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":308,"function":"encryptPassword","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","line":70,"function":"newToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/Manager.php","line":69,"function":"generateToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/User\/Session.php","line":641,"function":"generateToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/core\/Controller\/LoginController.php","line":322,"function":"createSessionToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":166,"function":"tryLogin","class":"OC\\Core\\Controller\\LoginController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":99,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\LoginController"},"tryLogin"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/App.php","line":118,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OC\\Core\\Controller\\LoginController"},"tryLogin"]},{"file":"\/var\/www\/nextcloud\/lib\/private\/AppFramework\/Routing\/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OC\\Core\\Controller\\LoginController","tryLogin",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"core.login.tryLogin"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"_route":"core.login.tryLogin"}]},{"file":"\/var\/www\/nextcloud\/lib\/private\/Route\/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"_route":"core.login.tryLogin"}]},{"file":"\/var\/www\/nextcloud\/lib\/base.php","line":987,"function":"match","class":"OC\\Route\\Router","type":"->","args":["\/login"]},{"file":"\/var\/www\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/nextcloud\/lib\/private\/Authentication\/Token\/PublicKeyTokenProvider.php","Line":242,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36 OPR\/57.0.3098.76","version":"14.0.4.2"}

Just bumping this to see if anyone else has had the issue or can direct me to a fix…

Well, I believe my password complexity is somewhat related to issue 11438 on GitHub.

I ended up using the command

sudo -u www-data /var/www/nextcloud/occ user:resetpassword username

to force a reset on the password and then I could log in and recover the files.