02-02-2017 10:14 - edited 02-02-2017 10:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-02-2017 10:14 - edited 02-02-2017 10:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm using Fitbit.NET to implement the integration into my api. I'm able to authenticate and get a code back for the server. But when I attemp to exchange it for an token. I get an error stating `redirect_url mismatch`.
URL Received From Fitbit API
http://localhost:49294/api/oauth2/callback?code=ba6de3....2b41e5
Callback URL for application @ dev.fitbit.com
http://localhost:49294/api/oauth2/callback
Request User Authorization URL
string authorizationLink; try { string[] scopes = {"profile", "activity", "heartrate", "weight", "location", "sleep", "nutrition"}; authorizationLink = Authenticator().GenerateAuthUrl(scopes); } catch (Exception e) { AppUtils.LogException(" FitbitHandler/RequestUserAuthorizationUrl ", e); authorizationLink = string.Empty; } return authorizationLink;
Get User Token
public async Task<OAuth2AccessToken> GetUserToken(string code) { if (_requestToken != null) return _requestToken; _requestToken = await Authenticator().ExchangeAuthCodeForAccessTokenAsync(code); return _requestToken; }
Authenticator
private OAuth2Helper Authenticator() { var appCredentials = new FitbitAppCredentials { ClientId = _consumerKey, ClientSecret = _consumerSecret }; return new OAuth2Helper(appCredentials, CallbackUrl); }
02-02-2017 17:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-02-2017 17:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Perhaps it's better to file an issue on the library's repository, since this library was not created by Fitbit.
This error means that the redirect_uri provided in the Access Token Request does not match the redirect_uri specified on the Authorization Page URL.
02-03-2017 14:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-03-2017 14:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@JeremiahFitbit Thanks for you response. I've already opened an issue here, but they've yet to respond. Is the callback_url equal to the redirect_url? If not how do I find the redirect_url?

02-04-2017 10:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-04-2017 10:45
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@antarr Redirect_uri parameter should match the callback URL in the app settings.

