本文介绍了C#clientcallback oauth2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请和我一起露面。新秀在街区。我的任务是提供clientcallback网址,这需要验证zoho桌面



主机:https://accounts.zoho.com

路径:/ oauth / v2 / auth

response_type:code

client_id:###

范围:Desk.tickets.READ,Desk.basic .READ,Desk.tickets.CREATE,Desk.basic.CREATE

redirect_uri:mydomain.com/authenticate



问题我是怎么做的创建一个页面调用它进行身份验证并获取令牌?



我尝试过:



Please bare with me. Rookie on the block. I am tasked to provide clientcallback url and this needed to authenticate zoho desk

host: https://accounts.zoho.com
path: /oauth/v2/auth
response_type: code
client_id: ###
scope: Desk.tickets.READ,Desk.basic.READ,Desk.tickets.CREATE,Desk.basic.CREATE
redirect_uri: mydomain.com/authenticate

Question is how do I create a page call it authenticate and get the token back?

What I have tried:

string baseAddress = "http://localhost/";
var client = new HttpClient();
var form = new Dictionary<string, string>
{
    {"grant_type", "client_credentials"},
    {"client_id", "clientId"},
    {"client_secret", "secretKey"},
};

var tokenResponse = client.PostAsync(baseAddress + "accesstoken", new FormUrlEncodedContent(form)).Result;
var token = tokenResponse.Content.ReadAsAsync<Token>(new[] { new JsonMediaTypeFormatter() }).Result;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
var authorizedResponse = client.GetAsync(baseAddress + "/api/Tests").Result;

推荐答案



这篇关于C#clientcallback oauth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 07:19