07-22-2021 13:34
07-22-2021 13:34
startup.cs
services.AddOAuth(options => { options.AuthenticationScheme = "FitBit-AccessToken"; options.AuthorizationEndpoint = "https://www.fitbit.com/oauth2/authorize"; options.TokenEndpoint = "https://api.fitbit.com/oauth2/token"; options.SaveTokensAsClaims = true; options.CallbackPath = new PathString("/signing-fitbit-token/"); options.ClientId = "[MY ID STRIPPED OUT]"; options.ClientSecret = "[MY SECRET STRIPPED OUT]"; options.DisplayName = "FitBit"; options.Scope.Add("activity"); options.Scope.Add("heartrate"); options.Scope.Add("location"); options.Scope.Add("nutrition"); options.Scope.Add("profile"); options.Scope.Add("settings"); options.Scope.Add("sleep"); options.Scope.Add("social"); options.Scope.Add("weight"); options.AutomaticAuthenticate = true; });
FitbitController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
namespace FitBit_Oauth.Controllers
{
[Route("[controller]/[action]")]
public class FitbitController : Controller
{
[HttpGet]
//[Get("Enterhere")]
[Headers("Authorization : Bearer")]//
public IActionResult Login()
{
return Challenge(new AuthenticationProperties() { RedirectUri = $"/" });
}
}
}
I have tried this to authenticate fitbit user and retrieve access token, but I am getting invalid redirect_uri.
Can anyone suggest here, how to implement it in asp.net core MVC?
08-04-2021 11:06
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.
08-04-2021 11:06
Hi @diggy016,
Welcome to the forums!
This error usually occurs when the redirect_uri in your application code does not match the redirect_uri you have in your application settings at dev.fitbit.com. Could you ensure that the two values match and try again?
Best Answer08-19-2021 11:55
08-19-2021 11:55
Hi John,
Thank you for the reply!
I have double check the URI and they are same.
Best Regards,
Diggy