Search code examples
.netwinformsoauthdeezer

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.

  • The Server-side flow is used by Web applications
  • The Client-side flow is used with browser client application in javascript and mobile applications.

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.


Solution

  • 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.