mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-04-05 17:37:54 +08:00
feat(wxapi): 随官方更新网页授权相关接口模型
This commit is contained in:
parent
2ec531eb97
commit
17a67d3a5b
@ -82,6 +82,21 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateParameterizedUrlForConnectOAuth2Authorize(this WechatApiClient client, string redirectUrl, string scope, string? state = null)
|
||||
{
|
||||
return GenerateParameterizedUrlForConnectOAuth2Authorize(client, redirectUrl: redirectUrl, scope: scope, state: state, forcePopup: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>生成公众号网页授权 URL。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="redirectUrl"></param>
|
||||
/// <param name="scope"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="forcePopup"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateParameterizedUrlForConnectOAuth2Authorize(this WechatApiClient client, string redirectUrl, string scope, string? state = null, bool? forcePopup = null)
|
||||
{
|
||||
return new Url(BASE_URL_OPEN)
|
||||
.AppendPathSegments("connect", "oauth2", "authorize")
|
||||
@ -90,6 +105,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
.SetQueryParam("response_type", "code")
|
||||
.SetQueryParam("scope", scope)
|
||||
.SetQueryParam("state", state)
|
||||
.SetQueryParam("forcePopup", forcePopup.HasValue ? forcePopup.Value ? "true" : "false" : null)
|
||||
.SetFragment("wechat_redirect")
|
||||
.ToString();
|
||||
}
|
||||
@ -105,6 +121,22 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateParameterizedUrlForComponentConnectOAuth2Authorize(this WechatApiClient client, string appId, string redirectUrl, string scope, string? state = null)
|
||||
{
|
||||
return GenerateParameterizedUrlForComponentConnectOAuth2Authorize(client, appId: appId, redirectUrl: redirectUrl, scope: scope, state: state, forcePopup: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>生成代公众号网页授权 URL。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/Official_Accounts/official_account_website_authorization.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="appId"></param>
|
||||
/// <param name="redirectUrl"></param>
|
||||
/// <param name="scope"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="forcePopup"></param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateParameterizedUrlForComponentConnectOAuth2Authorize(this WechatApiClient client, string appId, string redirectUrl, string scope, string? state = null, bool? forcePopup = null)
|
||||
{
|
||||
return new Url(BASE_URL_OPEN)
|
||||
.AppendPathSegments("connect", "oauth2", "authorize")
|
||||
@ -114,6 +146,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
.SetQueryParam("response_type", "code")
|
||||
.SetQueryParam("scope", scope)
|
||||
.SetQueryParam("state", state)
|
||||
.SetQueryParam("forcePopup", forcePopup.HasValue ? forcePopup.Value ? "true" : "false" : null)
|
||||
.SetFragment("wechat_redirect")
|
||||
.ToString();
|
||||
}
|
||||
|
@ -3,36 +3,8 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /sns/oauth2/access_token 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SnsOAuth2AccessTokenResponse : WechatApiResponse
|
||||
public class SnsOAuth2AccessTokenResponse : SnsOAuth2RefreshTokenResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置网页授权接口调用凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("access_token")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("access_token")]
|
||||
public string AccessToken { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置凭证有效期(单位:秒)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("expires_in")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("expires_in")]
|
||||
public int ExpiresIn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户刷新 AccessToken。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("refresh_token")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("refresh_token")]
|
||||
public string RefreshToken { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户全局标识。
|
||||
/// </summary>
|
||||
@ -41,10 +13,12 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
public string? UnionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户授权的作用域,使用逗号分隔。
|
||||
/// 获取或设置是否为快照页模式虚拟账号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("scope")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("scope")]
|
||||
public string Scope { get; set; } = default!;
|
||||
[Newtonsoft.Json.JsonProperty("is_snapshotuser")]
|
||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.NumericalBooleanConverter))]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("is_snapshotuser")]
|
||||
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalBooleanConverter))]
|
||||
public bool IsSnapshotUser { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,43 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [GET] /sns/oauth2/refresh_token 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class SnsOAuth2RefreshTokenResponse : SnsOAuth2AccessTokenResponse
|
||||
public class SnsOAuth2RefreshTokenResponse : WechatApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置网页授权接口调用凭证。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("access_token")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("access_token")]
|
||||
public string AccessToken { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置凭证有效期(单位:秒)。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("expires_in")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("expires_in")]
|
||||
public int ExpiresIn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户刷新 AccessToken。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("refresh_token")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("refresh_token")]
|
||||
public string RefreshToken { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户授权的作用域,使用逗号分隔。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("scope")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("scope")]
|
||||
public string Scope { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
@ -4,5 +4,6 @@
|
||||
"refresh_token": "REFRESH_TOKEN",
|
||||
"openid": "OPENID",
|
||||
"scope": "SCOPE",
|
||||
"unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
|
||||
"is_snapshotuser": 1,
|
||||
"unionid": "UNIONID"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user