WeChatOptions.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System.Collections.Generic;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.AspNetCore.Identity;
  6. using Winsoft.GOV.XF.WXCore.OAuth;
  7. namespace Microsoft.AspNetCore.Builder
  8. {
  9. /// <summary>
  10. /// Configuration options for <see cref="WeChatMiddleware"/>.
  11. /// </summary>
  12. public class WeChatOptions : OAuthOptions
  13. {
  14. /// <summary>
  15. /// Initializes a new <see cref="WeChatOptions"/>.
  16. /// </summary>
  17. public WeChatOptions()
  18. {
  19. AuthenticationScheme = WeChatDefaults.AuthenticationScheme;
  20. DisplayName = AuthenticationScheme;
  21. CallbackPath = new PathString("/signin-wechat");
  22. StateAddition = "#wechat_redirect";
  23. AuthorizationEndpoint = WeChatDefaults.AuthorizationEndpoint;
  24. TokenEndpoint = WeChatDefaults.TokenEndpoint;
  25. UserInformationEndpoint = WeChatDefaults.UserInformationEndpoint;
  26. //SaveTokens = true;
  27. //BaseScope (不弹出授权页面,直接跳转,只能获取用户openid),
  28. //InfoScope (弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息)
  29. WeChatScope = InfoScope;
  30. }
  31. // WeChat uses a non-standard term for this field.
  32. /// <summary>
  33. /// Gets or sets the WeChat-assigned appId.
  34. /// </summary>
  35. public string AppId
  36. {
  37. get { return ClientId; }
  38. set { ClientId = value; }
  39. }
  40. // WeChat uses a non-standard term for this field.
  41. /// <summary>
  42. /// Gets or sets the WeChat-assigned app secret.
  43. /// </summary>
  44. public string AppSecret
  45. {
  46. get { return ClientSecret; }
  47. set { ClientSecret = value; }
  48. }
  49. public string StateAddition { get; set; }
  50. public string WeChatScope { get; set; }
  51. public string BaseScope = "snsapi_base";
  52. public string InfoScope = "snsapi_userinfo";
  53. }
  54. }