Thư viện ứng dụng API Xác thực địa chỉ

Trang này cho biết cách bắt đầu sử dụng thư viện ứng dụng cho API xác thực địa chỉ.

Đọc thêm về thư viện ứng dụng trong phần Giải thích về thư viện ứng dụng.

Cài đặt thư viện ứng dụng

C#

Để biết thêm thông tin, hãy xem phần Thiết lập môi trường phát triển C#.

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

Thiết lập phương thức xác thực

Khi dùng thư viện ứng dụng, bạn sẽ dùng Thông tin xác thực mặc định của ứng dụng (ADC) để xác thực. Để biết thông tin về cách thiết lập ADC, hãy xem phần Cung cấp thông tin xác thực cho Thông tin xác thực mặc định của ứng dụng. Để biết thông tin về cách sử dụng ADC với thư viện ứng dụng, hãy xem bài viết Xác thực bằng thư viện ứng dụng.

Sử dụng thư viện ứng dụng

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);
    }
}

Tài nguyên khác