【问题标题】:Fitbit oauth2.0 asp.netFitbit oauth2.0 asp.net
【发布时间】:2021-07-26 21:15:21
【问题描述】:

以下代码的重定向 uri 无效。

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]
public IActionResult Login()
{
return Challenge(new AuthenticationProperties() { RedirectUri = $"/" });
}
}
}

我已尝试使用此方法对 fitbit 用户进行身份验证并检索访问令牌,但我得到了无效的 redirect_uri。

任何人都可以在这里建议,如何在 asp.net core MVC 中实现它?

【问题讨论】:

    标签: c# asp.net oauth-2.0 fitbit


    【解决方案1】:

    我不完全确定您的要求是什么,但您可以Fitbit.Net 而不是自己做这件事。它并不完美,但它需要大量的腿部工作。

    【讨论】:

      猜你喜欢
      • 2021-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-13
      • 2015-04-06
      • 1970-01-01
      • 2013-04-18
      相关资源
      最近更新 更多