Take the 2-minute tour ×

I am trying to create a Windows Store app which needs an authentication through OAuth2.

Prefered way should be WebAuthenticationBroker:

const string url = @"https://my.server.srv/mobile-auth/index.pl?"
                          + "client_id=CLIENTID"
                           + "&redirect_uri=https%3A%2F%2Fmy.server.srv
                           + "&response_type=code"

Uri startUri = new Uri(url);
Uri endUri = new Uri("https://my.server.srv");

WebAuthenticationResult webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startUri, endUri);
if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
    string token = webAuthenticationResult.ResponseData;

but the token is empty. There should be the server response, which is


passed in GET, which is compilant to OAuth2.

Do you know how to get that parameters, please?

EDIT: SOLVED. It started to work after passing "https://localhost" as redirect_uri / endUri.

share|improve this question
Have you verified that the server is returning the appropriate response with another method or tool (i.e. Fiddler)? Can you verify that the problem is the WebAuthenticationBroker? –  villecoder Oct 30 '12 at 14:16
Yes. The piece of code (code=a-secret-code ... _type=bearer) is got from test in Firefox and Chrome browsers. (I have hidden the name of the server and that access code.) My problem is realted only to WebAuthenticationBroker. –  eMko Oct 30 '12 at 14:19
add comment

1 Answer

I'd suggest you rather use a library such as Hammock.

Typically for OAuth2 you first do a request to get a request-token that will be associated with all subsequent requests. You can then use that token with your parameters to do an authenticate request which will then return the response object which you can act on.

Flickr probably has the best summarised explanation (with pictures!) of how the OAuth process works - http://www.flickr.com/services/api/auth.oauth.html

Good luck

share|improve this answer
Thank you for response. I know how the process works (and according that page it seems that Flickr uses OAuth 1, not OAuth 2). I couldn't find a website or a decent documentation oh Hammock or Hammock2, so I don't know exactly what it does. But if it's only a REST library, it is useless for me. I need to display a login page to user in Win Store app, let him login and catch a token. This is exactly what WebAuthenticationBroker should do. –  eMko Oct 31 '12 at 10:00
add comment

Your Answer


