Пример #1
0
        public async Task <string> GetTokenAsync(Option <TimeSpan> ttl)
        {
            DateTime startTime = DateTime.UtcNow;
            string   audience  = SasTokenHelper.BuildAudience(this.iotHubHostName, this.deviceId, this.moduleId);
            string   expiresOn = SasTokenHelper.BuildExpiresOn(startTime, ttl.GetOrElse(this.defaultTtl));
            string   data      = string.Join("\n", new List <string> {
                audience, expiresOn
            });
            string signature = await this.signatureProvider.SignAsync(data).ConfigureAwait(false);

            return(SasTokenHelper.BuildSasToken(audience, signature, expiresOn));
        }