private static void ValidateDefaultFormValues(OAuth20GrantBase grant) { if (grant.ClientId == null) { throw new ArgumentNullException(nameof(grant.ClientId), $"You are attempting to use {AutomatonConstants.OAuth20.OAUTH_20} grant type {AutomatonConstants.OAuth20.GRANT_TYPE_CLIENT_CREDENTIALS} but the {nameof(grant.ClientId)} is null"); } if (grant.ClientSecret == null) { throw new ArgumentNullException(nameof(grant.ClientSecret), $"You are attempting to use {AutomatonConstants.OAuth20.OAUTH_20} grant type {AutomatonConstants.OAuth20.GRANT_TYPE_CLIENT_CREDENTIALS} but the {nameof(grant.ClientSecret)} is null"); } if (grant.Scopes == null) { throw new ArgumentNullException(nameof(grant.Scopes), $"You are attempting to use {AutomatonConstants.OAuth20.OAUTH_20} grant type {AutomatonConstants.OAuth20.GRANT_TYPE_PASSWORD} but the {nameof(grant.Scopes)} list is null"); } }
public static IEnumerable <KeyValuePair <string, string> > CreateUsingGrantType(OAuth20GrantBase grant) { IEnumerable <KeyValuePair <string, string> > formKeyValuePairs = null; switch (grant.GrantType) { case GrantType.ClientCredentials: formKeyValuePairs = CreateUsingClientGrantType((OAuth20ClientGrant)grant); break; case GrantType.Password: formKeyValuePairs = CreateUsingPasswordGrantType((OAuth20PasswordGrant)grant); break; default: break; } return(formKeyValuePairs); }