/// <remarks>
        /// Based on the C# sample from: https://developers.google.com/maps/documentation/business/webservices
        /// </remarks>
        internal Uri Sign(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }
            if (ClientID == null)
            {
                throw new ArgumentNullException("userID");
            }
            if (string.IsNullOrWhiteSpace(SigningKey))
            {
                throw new ArgumentException("Invalid signing key.");
            }
            if (!ClientID.StartsWith("gme-"))
            {
                throw new ArgumentException("A user ID must start with 'gme-'.");
            }

            var urlSegmentToSign = uri.LocalPath + uri.Query + "&client=" + ClientID;

            byte[] privateKey = FromBase64UrlString(SigningKey);
            byte[] signature;

            using (var algorithm = new HMACSHA1(privateKey))
            {
                signature = algorithm.ComputeHash(Encoding.ASCII.GetBytes(urlSegmentToSign));
            }

            return(new Uri(uri.Scheme + "://" + uri.Host + urlSegmentToSign + "&signature=" + ToBase64UrlString(signature)));
        }