Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        private string MakeSignInurl()
        {
            var appInfo = new MsOAuthAppInfo(o365Type, clientId, clientSecret, GetRedirectPageUrl());

            return(appInfo.GetAuthorizeUrl());
        }