02-02-2017 10:14 - edited 02-02-2017 10:15
02-02-2017 10:14 - edited 02-02-2017 10:15
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
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
02-02-2017 17:15
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
02-03-2017 14:37
@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?
Best Answer02-04-2017 10:45
Community Moderator Alumni are previous members of the Moderation Team, which ensures conversations are friendly, factual, and on-topic. Moderators are here to answer questions, escalate bugs, and make sure your voice is heard by the larger Fitbit team. Learn more
02-04-2017 10:45
@antarr Redirect_uri parameter should match the callback URL in the app settings.
Best Answer