public sealed class AuthenticationRule : IMessage<AuthenticationRule>, IEquatable<AuthenticationRule>, IDeepCloneable<AuthenticationRule>, IBufferMessage, IMessage
Authentication rules for the service.
By default, if a method has any authentication requirements, every request
must include a valid credential matching one of the requirements.
It's an error to include more than one kind of credential in a single
request.
If a method doesn't have any auth requirements, request credentials will be
ignored.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003e\u003ccode\u003eAuthenticationRule\u003c/code\u003e is a class used to define authentication requirements for a service's methods, with each method needing a valid credential if authentication is required.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAuthenticationRule\u003c/code\u003e class implements interfaces such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, providing functionalities like deep cloning and message merging.\u003c/p\u003e\n"],["\u003cp\u003eThis class has several properties including \u003ccode\u003eAllowWithoutCredential\u003c/code\u003e, \u003ccode\u003eOauth\u003c/code\u003e, \u003ccode\u003eRequirements\u003c/code\u003e, and \u003ccode\u003eSelector\u003c/code\u003e, which determine the authentication behavior, OAuth requirements, additional provider needs, and method selection.\u003c/p\u003e\n"],["\u003cp\u003eKey fields associated with \u003ccode\u003eAuthenticationRule\u003c/code\u003e include \u003ccode\u003eAllowWithoutCredentialFieldNumber\u003c/code\u003e, \u003ccode\u003eOauthFieldNumber\u003c/code\u003e, \u003ccode\u003eRequirementsFieldNumber\u003c/code\u003e, and \u003ccode\u003eSelectorFieldNumber\u003c/code\u003e, each corresponding to specific settings or requirements.\u003c/p\u003e\n"],["\u003cp\u003eMethods of the \u003ccode\u003eAuthenticationRule\u003c/code\u003e class allow for actions such as calculating message size, creating clones, comparing instances, merging messages, and handling input/output streams for protocol buffer data.\u003c/p\u003e\n"]]],[],null,["# Class AuthenticationRule (2.17.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.17.0 (latest)](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.AuthenticationRule)\n- [2.15.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.15.0/Google.Api.AuthenticationRule)\n- [2.10.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.10.0/Google.Api.AuthenticationRule)\n- [2.2.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.2.0/Google.Api.AuthenticationRule) \n\n public sealed class AuthenticationRule : IMessage\u003cAuthenticationRule\u003e, IEquatable\u003cAuthenticationRule\u003e, IDeepCloneable\u003cAuthenticationRule\u003e, IBufferMessage, IMessage\n\nAuthentication rules for the service.\n\nBy default, if a method has any authentication requirements, every request\nmust include a valid credential matching one of the requirements.\nIt's an error to include more than one kind of credential in a single\nrequest.\n\nIf a method doesn't have any auth requirements, request credentials will be\nignored. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e AuthenticationRule \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[AuthenticationRule](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.AuthenticationRule), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[AuthenticationRule](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.AuthenticationRule), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[AuthenticationRule](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.AuthenticationRule), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)\n\nNamespace\n---------\n\n[Google.Api](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api)\n\nAssembly\n--------\n\nGoogle.Api.CommonProtos.dll\n\nConstructors\n------------\n\n### AuthenticationRule()\n\n public AuthenticationRule()\n\n### AuthenticationRule(AuthenticationRule)\n\n public AuthenticationRule(AuthenticationRule other)\n\nFields\n------\n\n### AllowWithoutCredentialFieldNumber\n\n public const int AllowWithoutCredentialFieldNumber = 5\n\nField number for the \"allow_without_credential\" field.\n\n### OauthFieldNumber\n\n public const int OauthFieldNumber = 2\n\nField number for the \"oauth\" field.\n\n### RequirementsFieldNumber\n\n public const int RequirementsFieldNumber = 7\n\nField number for the \"requirements\" field.\n\n### SelectorFieldNumber\n\n public const int SelectorFieldNumber = 1\n\nField number for the \"selector\" field.\n\nProperties\n----------\n\n### AllowWithoutCredential\n\n public bool AllowWithoutCredential { get; set; }\n\nIf true, the service accepts API keys without any other credential.\nThis flag only applies to HTTP and gRPC requests.\n\n### Descriptor\n\n public static MessageDescriptor Descriptor { get; }\n\n### Oauth\n\n public OAuthRequirements Oauth { get; set; }\n\nThe requirements for OAuth credentials.\n\n### Parser\n\n public static MessageParser\u003cAuthenticationRule\u003e Parser { get; }\n\n### Requirements\n\n public RepeatedField\u003cAuthRequirement\u003e Requirements { get; }\n\nRequirements for additional authentication providers.\n\n### Selector\n\n public string Selector { get; set; }\n\nSelects the methods to which this rule applies.\n\nRefer to \\[selector\\]\\[google.api.DocumentationRule.selector\\] for syntax\ndetails.\n\nMethods\n-------\n\n### CalculateSize()\n\n public int CalculateSize()\n\n### Clone()\n\n public AuthenticationRule Clone()\n\n### Equals(AuthenticationRule)\n\n public bool Equals(AuthenticationRule other)\n\n### Equals(object)\n\n public override bool Equals(object other)\n\n**Overrides** \n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object))\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### MergeFrom(AuthenticationRule)\n\n public void MergeFrom(AuthenticationRule other)\n\n### MergeFrom(CodedInputStream)\n\n public void MergeFrom(CodedInputStream input)\n\n### ToString()\n\n public override string ToString()\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### WriteTo(CodedOutputStream)\n\n public void WriteTo(CodedOutputStream output)"]]