2
我期待爲我的web api實施OAuth2授權,並將Google的文檔用作模型。我試圖實現的具體流程是「服務帳戶」流程:here(據我瞭解,它也被稱爲JWT承載令牌流?)。與IdentityServer v3的智威湯遜持票人流程
我該如何在我的MVC應用程序中使用Thinktecture來實現這個功能? (或者是有一個更好的選擇嗎?)
我期待爲我的web api實施OAuth2授權,並將Google的文檔用作模型。我試圖實現的具體流程是「服務帳戶」流程:here(據我瞭解,它也被稱爲JWT承載令牌流?)。與IdentityServer v3的智威湯遜持票人流程
我該如何在我的MVC應用程序中使用Thinktecture來實現這個功能? (或者是有一個更好的選擇嗎?)
您應該能夠使用相同的代碼,這是爲V2(https://github.com/thinktecture/Thinktecture.IdentityServer.v2/blob/master/samples/AdfsIntegrationSampleClient/AdfsIntegrationSampleClient/Program.cs#L123)的一部分提供的樣品中,所以:
var client = new HttpClient { BaseAddress = new Uri(idsrvEndpoint) };
var values = new Dictionary<string, string>
{
{ OAuth2Constants.GrantType, "urn:ietf:params:oauth:grant-type:jwt-bearer" },
{ OAuth2Constants.Assertion, jwt },
{ OAuth2Constants.Scope, realm }
};
var form = new FormUrlEncodedContent(values);
var response = client.PostAsync("", form).Result;
response.EnsureSuccessStatusCode();
var tokenResponse = response.Content.ReadAsStringAsync().Result;
var json = JObject.Parse(tokenResponse);
return json["access_token"].ToString();
這將是客戶端應用程序從我的應用程序請求訪問令牌,對嗎?其實我試圖找出服務器端,(即app.UseIdentityServer(......))。這個問題有意義嗎? – Roly
這個問題是有道理的,但我不熟悉那邊,對不起 –