These are imported from FBFP and slightly modified to be specific to YKPS
(while not being hard to port to other environments that use APIs that use
OAUTH 2.0). Some code is also simplified.
Database code still needs an audit, and things are not tested yet.