Answered by:
Walk-through for consuming a web service that uses ADFS

Question
-
I found many step by steps on ADFS but nothing that walksthrough on making a direct call to an ADFS service?
I have a web application and wrote this based on the Microsoft doc on ADFS but I get an error no matter what I use.
Is there something I have to set up in the web.config?
=================================
public string AuthorizationRequestToken(string uri, string resource_urn, string method = "POST", string redirect_uri = "", string code="")
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
request.Headers.Add("grant_type", "authorization_code");
request.Headers.Add("code", code);
request.Headers.Add("resource", resource_urn);
request.Headers.Add("client_id", Key);
request.Headers.Add("redirect_uri", redirect_uri);
request.Headers.Add("client_secret", Secret);
request.Method = method;
request.ContentType = "text/xml";
request.ContentLength = 0;
using (var response = (System.Net.HttpWebResponse)request.GetResponse())
{
using (var reader = new System.IO.StreamReader(response.GetResponseStream()))
{
var r = reader.ReadToEnd();
return r;
}
}
}
- Moved by Jack J JunMicrosoft contingent staff Friday, September 27, 2019 8:32 AM
Thursday, September 26, 2019 5:33 PM
Answers
-
Hello,
you could ask here: https://social.technet.microsoft.com/Forums/en-US/home?forum=ADFS
- Proposed as answer by Richard MuellerMVP, Banned Friday, September 27, 2019 12:38 PM
- Marked as answer by Richard MuellerMVP, Banned Friday, October 4, 2019 12:23 PM
Friday, September 27, 2019 8:41 AM
All replies
-
Hi ETAzero,
Thank you for posting here.
Since this thread is related to ADFS, I don't suggest that you post it here. Therefore, I will move it to where is forum for forum to redirect it to the correct forum.
The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.
Best Regards,
Jack
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Edited by Jack J JunMicrosoft contingent staff Friday, September 27, 2019 8:31 AM
Friday, September 27, 2019 8:31 AM -
Hello,
you could ask here: https://social.technet.microsoft.com/Forums/en-US/home?forum=ADFS
- Proposed as answer by Richard MuellerMVP, Banned Friday, September 27, 2019 12:38 PM
- Marked as answer by Richard MuellerMVP, Banned Friday, October 4, 2019 12:23 PM
Friday, September 27, 2019 8:41 AM -
And if it's more related to web service, then ask here: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=wwsapi
Regards, Guido
- Proposed as answer by Richard MuellerMVP, Banned Friday, September 27, 2019 12:38 PM
Friday, September 27, 2019 8:45 AM