0

Good morning, Guys!

Here's the context:

I am putting together an OAuth-handling program and I'm almost ready to make the call as described in step E of the OAuth Authentication Flow 1.0a diagram here: https://wiki.fitbit.com/display/API/OAuth+Authentication+in+the+Fitbit+API#OAuthAuthenticationintheFitbitAPI-TheOAuthFlow

The problem is all of the testing is taking place on a local machine, and step D of the flow returns a token and a verifier. I am not able to get access to those items in my code because there doesn't seem to be a URL shortener service that will work correctly with multiple returning parameters (neither goo.gl nor http://para.ms/index.php do the trick).

However, using Fiddler, I am able to view the token and the verifier... just not able to get access to them from my oauth callback method, as the parameters are stripped away by the URL shortener services.

I got the idea to copy and paste those items into my code (via some sort of console input such as Console.ReadLine) while it is running in debugger, and continue processing step E with the manually input values. However, I cannot seem to find a way to actually input the values into my code as it is running. The debugger merrily proceeds past the ReadLine command and the values remain null.

I looked at How to make Visual C# studio recognize key input and several other google results which all have to do with System.Windows.Forms. I cannot tell whether that is what I'm supposed to be using, or if there's some other way to get keyboard input.

So my question is: How do I get input from the keyboard in C# MVC while the VS2010 debugger is running? If there is an alternative or a workaround that someone is aware of that will allow me to give my code access to those values while it is running on my local machine, I would also welcome any suggestions.

Thanks to everyone in advance! - Eli

Community
  • 1
  • 1
justian17
  • 575
  • 1
  • 7
  • 17
  • You can try the immediate window: http://stackoverflow.com/questions/794255/how-do-you-use-the-immediate-window-in-visual-studio – Julián Urbano May 16 '14 at 14:02
  • You shouldn't be using a URL shortening service when dealing with OAuth authentication. Shortening services are just a shortcut to an actual URL, but they shouldn't carry authentication information with them. – Steve Mitcham May 16 '14 at 14:04
  • The immediate window did the trick! Thanks Julian; if you put it as an answer, I'd be happy to give you a green tick =). @SteveMitcham: I am not going to be using url shorteners in production code, but I need to use something in order for the API response to come back to my local machine. Currently, using a live server is not an option =(. – justian17 May 16 '14 at 14:11
  • Ok, have you tried setting up a local server using Node or something similar that you can use to emulate your backend environment? – Steve Mitcham May 16 '14 at 15:05
  • @SteveMitcham I have not; this is the first time I hear of it. If you're talking about http://nodejs.org/, then I owe you a big thank you because that thing looks pretty awesome... – justian17 May 16 '14 at 16:51
  • Yes, that's what I mean, we operate off network here and we use node for setting up test access servers with canned data for almost all our operations until we do our integration testing in a realistic environment with external servers. – Steve Mitcham May 16 '14 at 19:14

1 Answers1

0

I don't think that that is a realistic way for a production environment, but I put together a OAuth 2 Client myself and used a custom protocol (i.e. oauth://?code=...) that was called by the browser. This required registry entries (where "oauthclientcode" is the protocol name):

 [HKEY_CLASSES_ROOT\oauthclientcode]
@="URL:oauthclientcode Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\oauthclientcode\shell]

[HKEY_CLASSES_ROOT\oauthclientcode\shell\open]

[HKEY_CLASSES_ROOT\oauthclientcode\shell\open\command]
@="\"C:\\PATH_TO_EXE\" authresponse %1"

The Browser redirected to my application with the code as a parameter. I then parsed the input in my Main method.

Source of the OAuth2 Client if interested: https://github.com/Excape/oAuth2TestClient

Excape
  • 1
  • 1