我尝试使用Fitbit在我的WebApi应用程序中实现代码交换代码。我一直得到例外,Message = "Redirect_uri mismatch: http://localhost:49294/api/... Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
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;
public async Task<OAuth2AccessToken> GetUserToken(string code)
{
if (_requestToken != null)
return _requestToken;
_requestToken = await Authenticator().ExchangeAuthCodeForAccessTokenAsync(code);
return _requestToken;
}
private OAuth2Helper Authenticator()
{
var appCredentials = new FitbitAppCredentials
{
ClientId = _consumerKey,
ClientSecret = _consumerSecret
};
return new OAuth2Helper(appCredentials, CallbackUrl);
}
答案 0 :(得分:1)
您的重定向网址应与您在应用设置中提供的网址相匹配。