gcappon / fitbitter

A Flutter package to make your life easier when dealing with Fitbit APIs.
https://gcappon.github.io/fitbitter/
BSD 3-Clause "New" or "Revised" License
19 stars 21 forks source link

correct format of callbackUrlScheme #15

Closed Strain-solutions closed 1 year ago

Strain-solutions commented 1 year ago

Hi - I am mostly leaving this here to help the unwary after blundering around in the dark for a while. Maybe others implicitly realised this but I didn't.

If you follow the example file here or many of the OAuth tutorials on the web you will probably try to use your app ID or CFBundleID as your callbackUrlScheme. I did but I kept getting the error that my callbackUrlScheme was incorrect.

If you follow the code through to where that error comes from the web_auth package checks it against the following regular expression

static RegExp _schemeRegExp = new RegExp(r"^[a-z][a-z0-9+.-]*$");

Which essentially says the first character should be lowercase a-z and there can be any number of subsequent characters that are either a lowercase a-z, or 1-9 or . or + or -

this means anything with a captial such as camelCase or with_underscores will fail the check.

Android studio (and maybe VSCode but I don't use it) will force you to use a project_name_with_underscores when you set up a new project and will helpfully insert this into your info.plist as your CFBundleID, which if your a halfwit like me, you will then jutifully copy into your code and bang your head against a wall for an hour or so....