Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string  graphCallPath = "https://microsoftgraph.chinacloudapi.cn/v1.0/me/messages";
            JObject msgsReturnObj = MyHttpHelper.HttpRestGet(graphCallPath, accessToken);
            int     count         = msgsReturnObj["value"].Count();

            for (int i = 0; i < count; i++)
            {
                JToken msg = msgsReturnObj["value"][i];
                msgToShow += string.Format("标题:{0} <a href=\"{1}\">点击阅读</a>{2}<br /><br />", msg["subject"].Value <string>(), msg["webLink"].Value <string>(), System.Environment.NewLine);
            }
        }
Пример #2
0
        private void GetAccessToken(string authCode)
        {
            string redirectUrl = GetRedirectPageUrl();
            var    appInfo     = new MsOAuthAppInfo(o365Type, clientId, clientSecret, redirectUrl);

            string resourceUrl = appInfo.GetResourceUrl(o365Type);

            var postData = new Dictionary <string, string>
            {
                { "client_id", clientId },
                { "client_secret", clientSecret },
                { "redirect_uri", redirectUrl },
                { "code", authCode },
                { "grant_type", "authorization_code" },
                { "resource", resourceUrl }
            };

            JObject tokenObj = MyHttpHelper.HttpPostRequest(appInfo.GetTokenUrl(), postData);

            accessToken = tokenObj["access_token"].ToString();
        }