Add client secret and do some refactoring