projectgoav / E.Deezer

Unoffical asynchronous Deezer .NET API
16 stars 11 forks source link

OAuth #7

Open projectgoav opened 8 years ago

projectgoav commented 8 years ago

Allow in-lib authentication of users.

projectgoav commented 8 years ago

Try and do this without having to put up a web-page to authenticate users first before getting oauth codes

xfischer commented 8 years ago

Hi projectgoav, why not in a first step generate a token via https://developers.deezer.com/api/explorer, and prepare all the APIs to pass the access_token in the query string ? The token generation could be done in parallel, but would not impact the APIs.

projectgoav commented 8 years ago

From what I've read and used of the API so far, if you request a token with any permissions other than "offline_access" then the token expires after a certain amount of time. The idea would be that in the background, if the token has expired, the library would request a new one and retry the request.

I'll need to look into a bit more before I commit to anything, but what you've suggested probably the best idea for now.

projectgoav commented 8 years ago

As of 7b98e5d an access token can be passed in and most user (get) methods will now work, as per @xfischer's suggestion. An updated Nuget package + wiki docs will be out in a couple of days once I've fixed the few remaining bugs.

Patafoin commented 8 years ago

Hi projectgoav, Did you managed to implement oAuth into your library ? I've seen you've added some "oAuth stuff" into your code but I don't understand what I have to do to get identified. I would like to get the oAuth response accessToken to use it with the new native deezer SDK to play music. Thanks.

projectgoav commented 8 years ago

@Patafoin - TL;DR - My libary doesn't allow you to obtain access tokens via Deezer's OAuth service. It can only use them, but your application must provide them.

At the time of implementing, there was no way to get an access token from Deezer without using a pop-up webpage, allowing users to accept application permissions. That was outwith the scope of this library, and would add to many dependencies, so this is something you'll have to implement yourself.

I didn't know there was a new native library out, so I will need to have a look at this (thanks for pointing it out!). If it allows you to obtain a token without showing a pop-up up would be something I would certainly like to include in this library.

Patafoin commented 8 years ago

we can discuss about this in private if you want. I have contacted deezer devs team and they sent me a sample code to adapt native library into a CLI class. The only problem I have now (I've implemented oAuth through an embedded webbrowser) is that it returns me a USER_ACCESS_TOKEN_FAILED response when trying to connect with it... We could work together on this if you want. I've tried to contact you through your "contact" link on your web site but it redirects on your homepage.

projectgoav commented 8 years ago

I understand you can wrap up native libraries to make them callable in a .NET application. Having a quick look at the docs for the native library I don't see how it is any different from what I have implemented here as you still need to provide an access token you have obtained through some other method but, it does give you the ability to play tracks.

I'm pretty busy the now, but will definately get around to looking at the natvie library in more detail and perhaps incorporate it into this library in the coming months.

Patafoin commented 8 years ago

It's my main goal :) being able to play songs without using any web plugin or anything else.

projectgoav commented 8 years ago

If you're wanting to do that, why not just use the Javascript SDK? Then you can have a hidden webview that is the player which you control through your application? Someone else a while back was asking about how to play songs and they suggested that. It's a similar approach to how the Miam-Player allows you to play Deezer songs.

Patafoin commented 8 years ago

Thanks for your advice. I've already tried to do that but didn't managed to make it work. Currently, the deezer plugin for miam-player isn't available anymore. I've written to the author to know if he will be able to make it available again (he is rewriting it into a new version).