Browse Source

Add Meetup to the list of supported providers

pull/2007/head
Kévin Chalet 2 years ago
parent
commit
ad3cb994c2
  1. 17
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs
  2. 28
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs
  3. 38
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml

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

@ -69,8 +69,9 @@ public static partial class OpenIddictClientWebIntegrationHandlers
request.Method = context.Registration.ProviderType switch
{
// SubscribeStar's userinfo implementation is based on GraphQL, which requires using POST.
ProviderTypes.SubscribeStar => HttpMethod.Post,
// The userinfo endpoints exposed by these providers
// are based on GraphQL, which requires using POST:
ProviderTypes.Meetup or ProviderTypes.SubscribeStar => HttpMethod.Post,
_ => request.Method
};
@ -266,10 +267,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers
request.Content = context.Registration.ProviderType switch
{
// SubscribeStar's userinfo implementation is based on GraphQL,
// which requires sending the request parameters as a JSON payload.
ProviderTypes.SubscribeStar => JsonContent.Create(context.Transaction.Request,
new MediaTypeHeaderValue(MediaTypes.Json)
// The userinfo endpoints exposed by these providers are based on GraphQL,
// which requires sending the request parameters as a JSON payload:
ProviderTypes.Meetup or ProviderTypes.SubscribeStar
=> JsonContent.Create(context.Transaction.Request, new MediaTypeHeaderValue(MediaTypes.Json)
{
CharSet = Charsets.Utf8
}),
@ -398,6 +399,10 @@ public static partial class OpenIddictClientWebIntegrationHandlers
=> new(context.Response["data"]?.GetNamedParameters() ??
throw new InvalidOperationException(SR.FormatID0334("data"))),
// Meetup returns a nested "self" object that is itself nested in a GraphQL "data" node.
ProviderTypes.Meetup => new(context.Response["data"]?["self"]?.GetNamedParameters() ??
throw new InvalidOperationException(SR.FormatID0334("data/self"))),
// Nextcloud returns a nested "data" object that is itself nested in a "ocs" node.
ProviderTypes.Nextcloud => new(context.Response["ocs"]?["data"]?.GetNamedParameters() ??
throw new InvalidOperationException(SR.FormatID0334("ocs/data"))),

28
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs

@ -885,6 +885,15 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.UserinfoRequest["fields"] = string.Join(",", settings.Fields);
}
// Meetup's userinfo endpoint is a GraphQL implementation that requires
// sending a proper "query" parameter containing the requested user details.
else if (context.Registration.ProviderType is ProviderTypes.Meetup)
{
var settings = context.Registration.GetMeetupSettings();
context.UserinfoRequest["query"] = $"query {{ self {{ {string.Join(" ", settings.UserFields)} }} }}";
}
// Patreon limits the number of fields returned by the userinfo endpoint
// but allows returning additional information using special parameters that
// determine what fields will be returned as part of the userinfo response.
@ -1118,12 +1127,6 @@ public static partial class OpenIddictClientWebIntegrationHandlers
context.UserinfoResponse?.HasParameter("last_name") is true
=> $"{(string?) context.UserinfoResponse?["first_name"]} {(string?) context.UserinfoResponse?["last_name"]}",
// These providers return the username as a custom "name" node:
ProviderTypes.Deezer or ProviderTypes.Facebook or ProviderTypes.GitHub or
ProviderTypes.Reddit or ProviderTypes.SubscribeStar or ProviderTypes.Twitter or
ProviderTypes.Vimeo
=> (string?) context.UserinfoResponse?["name"],
// FitBit returns the username as a custom "displayName" node:
ProviderTypes.Fitbit => (string?) context.UserinfoResponse?["displayName"],
@ -1189,12 +1192,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers
=> (string?) context.UserinfoResponse?["username"],
// These providers return the user identifier as a custom "id" node:
ProviderTypes.Basecamp or ProviderTypes.Dailymotion or ProviderTypes.Deezer or
ProviderTypes.Discord or ProviderTypes.Disqus or ProviderTypes.Facebook or
ProviderTypes.GitHub or ProviderTypes.Harvest or ProviderTypes.Kroger or
ProviderTypes.Lichess or ProviderTypes.Nextcloud or ProviderTypes.Patreon or
ProviderTypes.Reddit or ProviderTypes.Smartsheet or ProviderTypes.Spotify or
ProviderTypes.SubscribeStar or ProviderTypes.Twitter or ProviderTypes.Zoom
ProviderTypes.Basecamp or ProviderTypes.Dailymotion or ProviderTypes.Deezer or
ProviderTypes.Discord or ProviderTypes.Disqus or ProviderTypes.Facebook or
ProviderTypes.GitHub or ProviderTypes.Harvest or ProviderTypes.Kroger or
ProviderTypes.Lichess or ProviderTypes.Meetup or ProviderTypes.Nextcloud or
ProviderTypes.Patreon or ProviderTypes.Reddit or ProviderTypes.Smartsheet or
ProviderTypes.Spotify or ProviderTypes.SubscribeStar or ProviderTypes.Twitter or
ProviderTypes.Zoom
=> (string?) context.UserinfoResponse?["id"],
// Bitbucket returns the user identifier as a custom "uuid" node:

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

@ -779,6 +779,44 @@
</Environment>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▀▄ ██ ▄▄▄██ ▄▄▄█▄▄ ▄▄██ ██ ██ ▄▄ ██
██ █ █ ██ ▄▄▄██ ▄▄▄███ ████ ██ ██ ▀▀ ██
██ ███ ██ ▀▀▀██ ▀▀▀███ ████▄▀▀▄██ █████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->
<Provider Name="Meetup" Id="3eb9d2c2-e999-41f3-905e-07b97f054e8e"
Documentation="https://www.meetup.com/api/authentication/#p01-using-oauth2-section">
<Environment Issuer="https://www.meetup.com/">
<Configuration AuthorizationEndpoint="https://secure.meetup.com/oauth2/authorize"
TokenEndpoint="https://secure.meetup.com/oauth2/access"
UserinfoEndpoint="https://api.meetup.com/gql">
<GrantType Value="authorization_code" />
<GrantType Value="refresh_token" />
</Configuration>
</Environment>
<Setting PropertyName="UserFields" ParameterName="fields" Collection="true" Type="String"
Description="The list of user fields to expand from the GraphQL endpoint (by default, most basic fields are requested)">
<Item Value="birthday" Default="true" Required="false" />
<Item Value="city" Default="true" Required="false" />
<Item Value="country" Default="true" Required="false" />
<Item Value="email" Default="true" Required="false" />
<Item Value="gender" Default="true" Required="false" />
<Item Value="id" Default="true" Required="false" />
<Item Value="memberUrl" Default="true" Required="false" />
<Item Value="name" Default="true" Required="false" />
<Item Value="preferredLocale" Default="true" Required="false" />
<Item Value="state" Default="true" Required="false" />
<Item Value="status" Default="true" Required="false" />
<Item Value="timezone" Default="true" Required="false" />
<Item Value="username" Default="true" Required="false" />
<Item Value="zip" Default="true" Required="false" />
</Setting>
</Provider>
<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ▄▀▄ █▄ ▄██ ▄▄▀██ ▄▄▀██ ▄▄▄ ██ ▄▄▄ ██ ▄▄▄ ██ ▄▄▄█▄▄ ▄▄███ ▄▄▀██ ▄▄▀██ ▄▄▀██ ▄▄▄ ██ ██ ██ ▀██ █▄▄ ▄▄██

Loading…
Cancel
Save