Example #1
0
        public static string GetLogoutUrl()
        {
            IDictionary <string, string> urlParams = new Dictionary <string, string>();

            urlParams["post_logout_redirect_uri"] = AppSettings.LogoutUri;

            string url = string.Format("{0}/Common/oauth2/logout", AppSettings.AzureADInstance);

            return(AppUtilities.CombineUrl(url, urlParams));
        }
Example #2
0
        public static string GetLoginUrl()
        {
            IDictionary <string, string> urlParams = new Dictionary <string, string>();

            urlParams["client_id"]     = AppSettings.ClientId;
            urlParams["response_type"] = AppSettings.ResponseType;
            urlParams["redirect_uri"]  = AppSettings.RedirectUri;
            urlParams["response_mode"] = AppSettings.ResponseMode;
            urlParams["state"]         = Guid.NewGuid().ToString();
            string url = string.Format("{0}/{1}/oauth2/authorize", AppSettings.AzureADInstance,
                                       AppSettings.DirectoryId);

            return(AppUtilities.CombineUrl(url, urlParams));
        }
Example #3
0
        public static ResponseModel <AccessTokenResponseModel> GetAccessToken(string code, string RedirectUri)
        {
            string url = string.Format("{0}/{1}/oauth2/token", AppSettings.AzureADInstance,
                                       AppSettings.DirectoryId);
            StringBuilder postData = new StringBuilder();

            AppendUrlEncoded(postData, "grant_type", AppSettings.GrantType);
            AppendUrlEncoded(postData, "client_id", AppSettings.ClientId);
            AppendUrlEncoded(postData, "code", code);
            //AppendUrlEncoded(postData, "redirect_uri", AppSettings.RedirectUri);
            AppendUrlEncoded(postData, "redirect_uri", RedirectUri);
            AppendUrlEncoded(postData, "client_secret", AppSettings.ClientSecret);
            AppendUrlEncoded(postData, "resource", AppSettings.Resource);
            var result = AppUtilities.MakeWebRequest <AccessTokenResponseModel>(url, "POST", "application/x-www-form-urlencoded", postData.ToString());

            return(result);
        }