added null check for api and secret. Use config values if not provided as argument