Address Validation API 客户端库

此页面介绍了如何开始使用 Address Validation API 的客户端库。

如需详细了解客户端库,请参阅客户端库 说明

安装客户端库

C#

如需了解详情,请参阅 设置 C# 开发环境

Install-Package Google.Maps.AddressValidation.V1 -Pre

设置身份验证

使用客户端库时,您可以使用 应用默认凭据 (ADC) 进行身份验证如需了解如何设置 ADC,请参阅为应用默认凭据提供凭据。如需了解如何将 ADC 与客户端库搭配使用,请参阅使用客户端库进行身份验证

使用客户端库

C#

using Google.Maps.AddressValidation.V1;
using Google.Type;
using System.Threading.Tasks;

public sealed partial class GeneratedAddressValidationClientSnippets
{
    /// <summary>Snippet for ValidateAddressAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task ValidateAddressRequestObjectAsync()
    {
        // Create client
        AddressValidationClient addressValidationClient = await AddressValidationClient.CreateAsync();
        // Initialize request argument(s)
        ValidateAddressRequest request = new ValidateAddressRequest
        {
            Address = new PostalAddress(),
            PreviousResponseId = "",
            EnableUspsCass = false,
            SessionToken = "",
        };
        // Make the request
        ValidateAddressResponse response = await addressValidationClient.ValidateAddressAsync(request);
    }
}

其他资源