Skip to content

Instantly share code, notes, and snippets.

@tomasjurasek
Created June 12, 2019 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasjurasek/ba7f22ae563ee76330e7529f902c9a78 to your computer and use it in GitHub Desktop.
Save tomasjurasek/ba7f22ae563ee76330e7529f902c9a78 to your computer and use it in GitHub Desktop.
public class CustomGrantType : ICustomGrantValidator
{
public string GrantType => "wechat_credentials";
public Task<CustomGrantValidationResult> ValidateAsync(ValidatedTokenRequest request)
{
var wechatToken = request.Raw.Get("wechat_token");
var wechatUnionId = request.Raw.Get("wechat_unionId");
if (string.IsNullOrWhiteSpace(wechatToken))
{
return Task.FromResult<CustomGrantValidationResult>(
new CustomGrantValidationResult($"Missing parameter wechat_token"));
}
if (string.IsNullOrWhiteSpace(wechatUnionId))
{
return Task.FromResult<CustomGrantValidationResult>(
new CustomGrantValidationResult($"Missing parameter wechat_unionId"));
}
return Task.FromResult(new CustomGrantValidationResult());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment