第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C# - etcd GRPC 客戶端基本身份驗證

C# - etcd GRPC 客戶端基本身份驗證

C#
有只小跳蛙 2021-07-09 07:06:18
我正在嘗試為 etcd v3+ 實(shí)現(xiàn) C# GRPC 客戶端。我能夠通過無身份驗證和通道 ssl 身份驗證進(jìn)行連接。但是,我也在嘗試找出基本的身份驗證機(jī)制。這是我的實(shí)現(xiàn)。using System;using System.Threading.Tasks;using System.Collections.Generic;using Grpc.Core;using Etcdserverpb;using Google.Protobuf;using System.Runtime.CompilerServices;using Grpc.Auth;using Grpc.Core.Interceptors;namespace myproj.etcd{    public class EtcdClient    {               Channel channel;        KV.KVClient kvClient;        string host;        string username;        string password;        string authToken;        Auth.AuthClient authClient;        public EtcdClient(string host, string username, string password)        {            this.username = username;            this.password = password;            this.host = host;                             Authenticate();            // Expirementing with the token, trying to achieve my goal.            channel = new Channel(host, ChannelCredentials.Create(ChannelCredentials.Insecure,                                                                GoogleGrpcCredentials.FromAccessToken(this.authToken)));            // This works.            //channel = new Channel(host, ChannelCredentials.Insecure);            kvClient = new KV.KVClient(channel);        }        void Authenticate()        {            authClient = new Auth.AuthClient(new Channel(host,ChannelCredentials.Insecure));            var authRes = authClient.Authenticate(new AuthenticateRequest            {                Name = username,                Password = password            });            this.authToken = authRes.Token;        }使用authenticate()方法,我能夠從 etcd 服務(wù)器獲取令牌,但無法找到在后續(xù)調(diào)用(Get、Put 等)中使用相同令牌的方法。
查看完整描述

1 回答

?
慕斯王

TA貢獻(xiàn)1864條經(jīng)驗 獲得超2個贊

我通過參考此處的REST api 文檔解決了這個問題。

添加私有屬性。

Metadata headers;

更新Autheticate()以添加身份驗證標(biāo)頭。

headers = new Metadata();
headers.Add("Authorization", authToken);

更新Get()以傳遞標(biāo)頭。

var rangeResponse = kvClient.Range(rangeRequest, headers);


查看完整回答
反對 回復(fù) 2021-07-10
  • 1 回答
  • 0 關(guān)注
  • 375 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號