SimpleAuth icon indicating copy to clipboard operation
SimpleAuth copied to clipboard

Define constants for the keys in the configuration

Open alexito4 opened this issue 10 years ago • 3 comments

Hi! What do you think about using constants for the keys in the configuration dictionaries? It would be nice that each provider has the constants that it expects for the keys. I think that using simply strings its much error prone. Also, with the constants defined in each provider header file, the consumer would have more documentation about how to use the provider ;)

alexito4 avatar Feb 13 '14 18:02 alexito4

Yeah this is something I've been asked about and I'm not sure what to think. Defining constants in every provider means a consumer needs to import provider headers whenever they want to use it. The API was designed so you wouldn't have to import the providers directly or even know about them at all. I think requiring people to import the providers means we should change how the API works fundamentally. What are your thoughts?

calebd avatar Feb 13 '14 18:02 calebd

Autx that's true! In that case forget about defining constants in each provider, I really like how the API works and the decoupling with the providers. But... what about having one single file with the constants? SimpleAuth should import (publicly) that file and then the consumer would have access. Also the providers are already importing SimpleAuth so this should work. So I don't know if it's a good thing to have all this definitions in one single (and probably big) file but I think it's another solution. Maybe there is some other magic way of having the compiler checking the keys (and autocompletion).

alexito4 avatar Feb 13 '14 18:02 alexito4

Luckily, the core concepts of most of the providers are all the same, so I could probably define a handful of them and cover a lot of the bases and provide the outliers separately.

calebd avatar Feb 14 '14 01:02 calebd