Larry
Larry

Reputation: 18031

How to use the oAuth authentication of the Deezer API with a desktop application?

I am starting to write a Winforms application that uses the Deezer Api.

For now, I am stuck with their OAuth authentication process.

The OAuth authentication process of Deezer accepts two differents flows to get the user authenticated and authorized : the Server-side flow and the Client-side flow.

I assumed (maybe wrongly) I could use the Client-side flow to get a user authenticated in a Winforms application :

Then I wrote a form that launch the Deezer Login Web Page in a WebBrowser control, thinking I could parse the Response after to get the access token. Normally, the page allows it if I add the response_type=token parameter to the login page URL.

Unfortunately, there is a redirect_uri parameter has to be provided too. However, I dont plan to use a web site because it is not applicable in my scenario.

Apparently, there is no way to trick this, and the login page shows an error message saying it is missing and refuses to start the authentication process.

Before to ask Deezer about how to use their API against a Winform application, I would like to know if someone already bumped into this, and how he managed to solve it.

Because I am new to OAuth, I am wondering if I am missing some point, or if the Deezer API is not applicable to my scenario.

Upvotes: 3

Views: 4947

Answers (2)

Christopher
Christopher

Reputation: 98

I have tried to get a workaround for your problem. This is what I have :

  1. Using your web browser control, navigate to the OAuth connect URI,
  2. Use a domain/subdomain you control as a redirect URI. We don't need a real web service behind. For example http://deezerauth.maneu.net
  3. Add an event handler to the Navigating event of the WebBrowser control.

In this event handler, do something like the following code.

if(e.Uri.AbsoluteUri.Contains("http://deezerauth.maneu.net"))
{
    e.Cancel = true;
    MessageBox.Show("Welcome on Deezer.");
}

Disclaimer : I work for Deezer mobile team, and not in the API Team. I have forwarded this question to them to see if they have a better solution.

Upvotes: 2

Larry
Larry

Reputation: 18031

I finally have found a hack for redirect_uri :

"http://blank.org" is working! At the condition I put "blank.org" as the domain name for my application in the appropriate Deezer MyApp screen.

https://connect.deezer.com/fr/oauth/auth.php?
      app_id=******&redirect_uri=http://blank.org&perms=basic_access
      &response_type=token

Then the access token appears in the url, I just have to get it from the WebBrowser control!

I will take this as a temporary solution, before finding something else more elegant.

EDIT: forget about http://blank.org !

It seems to be a very bad idea to put a site we don't own as a dummy domain name. If the site actually exists, the redirected URL that contains our access_token will be logged by their web servers, which is very bad. The best is to define a dummy domain name that does not exists, then put http:// in front of it in the redirect_uri parameter. I will be thrown a "site not found", but at least I will get my access_token.

Upvotes: 1

Related Questions