I am working on a POC for IdentityServer3.
I have a version of sample app WebHost (minimal) running alright.
For the client sample app I am using the wpf client (hybrid with pkce).
I need the hybrid example because the webhost has been modified to use a custom ExternalRegistrationUserService.
However, all the samples they have for the hybrid clients use the webserver navigating event which uses a threading model not recommended for console apps/windows services.
The punchline question is, is there a console friendly equivalent to navigating that's not tied to a ui control?
httpwebrequest almost does what I want but identityserver3 seems to want to send multiple responses in a chain that I need to intercept and any httpclient or httpwebrequest call I make seems to want to return the first response only.
I just wrote a very similar POC using information from a recent blog post by Dominick Baier.
Essentially, this approach has the native client app using a combination of the newish IdentityModel.OidcClient library and a local HTTP listener to receive redirects.
I contributed to one of Dominick's samples that shows how the OidcClient can be used with the HTTP listener to enable the hybrid flow in a console application. You can find the code here.
I think this sample will do what you are after, but it does externally pop open the system web browser. However, the OidcClient also supports a user supplied WebView if you wanted to do everything inside the native client.
Related
I'm developing a website in C# MVC including WEB API. When an API URL in my project is called from an external system, I want to show a message (not a push message, only show a text in a div) in one of my view that the API function is executing.Is this possible?
First Of All its possible yes,
you need To use SignalR To notify the Views:
YouTube totrual Here
Github : Here
Then You use the Signal R to push a Notification when a cross origin request happen
using action filters
the signalR subscribers can be view pages using Jquery.
SignalR on Client
full exmaple :here
Yes it is posssible. One (pretty easy) way is to use the awesome SignalR or SignalR core framework. Check this for differences. Real-time web functionality enables server-side code to push content to clients instantly.
Basically you will create a Hub on the server that clients connect to. In your WebApi method, you can then call the client method. Then in the client you will use javascript to respond to the server call and then you will set the div content from this method.
See the docs.
Hope it helps!
I think Signal R is best choise too. But maybe you want to another alternative. You can look at Node Js.
Node js.org
General Tutorial
General Tutorial 2
For .NET Tutorial
I have a c#-based program that can send messages and files to our SlackWorkspace via my SlackApp (I'm using HttpClient to communicate with Slack).
Now, to distribute this program in my workspace and to make it so that every user will have his own identity, it says that I have to use OAuth and create verification-tokens, specific for each user.
It says in the Slack-documentation I have to use a redirect-URL (as per docs) to my own server.
We have a server that I potentially could use for this. But I have never done anything like this before and I am unclear on what "answer" I have to provide from our server. I thought the verification-process would be handled by Slack.
Anyone has an idea on how to approach this?
And before anyone asks - yes we need to install it for everyone and make them identifiable as themselves. We can't use the "SlackApp" as user. :)
I would be very grateful for code examples(in c#) and explanations on how this whole redirect-thing is working.
Slack uses the standard Oauth 2.0 protocol to authenticate apps, similar to Google and Facebook.
So the "verification-process" is indeed mostly handled by Slack (as outlined here), but your Slack app needs to initiate it and handle the responses properly. Also its a multi-step process and includes the user having to login into Slack with their credentials. This why you need a web app to handle the whole process.
To enable a Slack app to generate tokens via Oauth a web app is needed:
can be reached from the Internet
able to handle HTTP requests like a web server
has persistent storage for the newly generated tokens
This is probably easier to implement with ASP.NET Web Pages, which can utilize many functions from an existing web server.
But for this answer, lets look on an implementation in .NET Core. For that we need to create our own web server and some rudimentary session handling. Main concepts include:
HttpListener class for providing fundamental ability to listen and respond to HTTP requests
Handle multiple requests in parallel
Cookies / Session handling
MD5 hashes
The details go a bit beyond the scope of one answer. But I am happy to share a working example implementation on this GitHubGist.
Btw: For the local development of such a web app its recommend to use a VPN tunnel like ngrok, that allows one to expose a local machine securely to the Internet and Slack.
I would like to implement SignalR into one of my WPF applications for its real-time capabilities to communicate between client and server. However, everything I have read points to SignalR only being used on web browsers. Would it be possible to use SignalR in my application that does not include any web browsers (without adding a WebBrowser element to my project displays)? To try to clarify, I would like to use all the perks of SignalR such that a couple displays in my application update their data in real time, with no web browsers. If so, what would this look like? Thanks!
Yes, SignalR has .NET, Java, and JavaScript clients. A web browser isn't necessary. Technically anything that knows one of the transport protocols that SignalR provides (such as web sockets) could have a client written for it.
I'd like to capture webhooks from GitHub (for various events, like commits, etc), from my C# console application. I figured I could "listen" to an endpoint and webhooks would be thrown there, but it seems that perhaps github is actually sending webhooks to endpoints that you need to setup and listen from.
If the latter is this case, then I suppose I'll need to setup a web server to capture the webhooks. If the former is the case, then I'm not finding in the docs how I can listen for webhooks from GitHub?
Your question isn't very clear, but I think you're on the right track vis-a-vis implementing a web server. So, my answer to your question is: you need to implement a web server to receive the webhook requests.
Edit
At the bottom of this document, you will find instructions on how to implement a very simple web server (in Ruby) to receive GitLab webhook requests. I know this isn't a turnkey solution for you, but hopefully it will help get you going.
i want to interact via code with a silverlight (ver. 4) website.
i need to scrape data from the silverlight object as well as click on buttons.
what would be the simple way to do this from c# ?
what would be the simple way to do this from c++ ?
There is no such thing as a "Silverlight Website". Silverlight is a client-side technology.
Perhaps you could use something like Fiddler to examine the client to server conversation as the silverlight app is used. You might then be able to emulate it in a C++ or C# application.
Otherwise you will need some scriptable UI testing tool perhaps.
I doubt that you can scrape any data from the Silverlight control directly. If you "view source" on the page, that's all you will be able to get by scraping the page the control runs in.
UPDATE:
Anthony makes a good point that you might be able to observe the client/server communication. Fiddler is a good tool to see what's happening in that communication. If you find that the data you need is accessible in that communication, you could modify an http proxy to intercept the traffic and pull out the data you are interested in. You would tell your web browser to go to your http proxy, and the http proxy would then connect to the internet (or your existing proxy if you use one).
There are numerous http proxies available with source code. Here's a very simple one: http://code.cheesydesign.com/?p=393
For what I gather from your very brief description of your problem I'm going to jump to the conclusion that you want to do basically what Sliverlight Spy does. Checkout this blog post describing someone trying to emulate a little of what Spy does:
http://blog.aschommer.de/page/Injecting-code-into-Silverlight-applications.aspx
He's using Fiddler to modify the binaries in the XAP as they are downloaded, but before they're loaded by the SL plug-in. Pretty complicated.
Alternatively, I wonder if there something that could be done with a hosted browser in a C++/C# application, dynamic injection of javascript into the hosted page, and the Javascript API that SL exposes.