Store credentials only in session if required

Fixes:
- https://github.com/owncloud/core/issues/7199
Use the public api for random strings here?