Browse Source

Add Fitbit to the list of supported providers

pull/1716/head
Kévin Chalet 3 years ago
parent
commit
55b4e43a3d
  1. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs
  2. 27
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs

@ -212,6 +212,11 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.Response = context.Registration.ProviderName switch
{
// Fitbit returns a nested "user" object.
Providers.Fitbit => (JsonElement) context.Response["user"]
is { ValueKind: JsonValueKind.Object } element ?
new(element) : throw new InvalidOperationException(SR.FormatID0334("user")),
// StackExchange returns an "items" array containing a single element.
Providers.StackExchange => (JsonElement) context.Response["items"]
is { ValueKind: JsonValueKind.Array } element && element.GetArrayLength() is 1 ?

27
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

@ -178,6 +178,33 @@
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▄▄█▄ ▄█▄▄ ▄▄██ ▄▄▀█▄ ▄█▄▄ ▄▄██
██ ▄▄███ ████ ████ ▄▄▀██ ████ ████
██ ████▀ ▀███ ████ ▀▀ █▀ ▀███ ████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Fitbit" Documentation="https://dev.fitbit.com/build/reference/web-api/developer-guide/authorization/">
<Environment Issuer="https://www.fitbit.com/">
<Configuration AuthorizationEndpoint="https://www.fitbit.com/oauth2/authorize"
TokenEndpoint="https://api.fitbit.com/oauth2/token"
UserinfoEndpoint="https://api.fitbit.com/1/user/-/profile.json">
<CodeChallengeMethod Value="plain" />
<CodeChallengeMethod Value="S256" />
<TokenEndpointAuthMethod Value="client_secret_basic" />
</Configuration>
<!--
Note: Fitbit requires sending the "profile" scope to be able to use the userinfo endpoint.
-->
<Scope Name="profile" Default="true" Required="true" />
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▄ █▄ ▄█▄▄ ▄▄██ ██ ██ ██ ██ ▄▄▀██

Loading…
Cancel
Save