URI encode clientId for referrer parameter
Read optional client secret configuration to ensure we can use Basic auth as well
Refactored to use switch with fall through for readability