oauth2server: authorization flow fixes

Fixes issues with the oauth2server authorization flow as well as adds test for restful APIS.

Supersedes PR #2003 
261: D102 Docstring missing
264: D102 Docstring missing
267: D102 Docstring missing
270: D102 Docstring missing
273: D102 Docstring missing
287: D102 Docstring missing
307: D102 Docstring missing
310: D102 Docstring missing
313: D102 Docstring missing
328: D102 Docstring missing
331: D102 Docstring missing
334: D102 Docstring missing
337: D102 Docstring missing
340: D102 Docstring missing
343: D102 Docstring missing
359: D102 Docstring missing
371: D102 Docstring missing
374: D102 Docstring missing
377: D102 Docstring missing
380: D102 Docstring missing
393: D102 Docstring missing
402: D102 Docstring missing
405: D102 Docstring missing
408: D102 Docstring missing
411: D102 Docstring missing
414: D102 Docstring missing
496: D102 Docstring missing
499: D102 Docstring missing
502: D102 Docstring missing
505: D102 Docstring missing
536: D102 Docstring missing
578: D102 Docstring missing
581: D102 Docstring missing
584: D102 Docstring missing
591: D103 Docstring missing