dart-reddit icon indicating copy to clipboard operation
dart-reddit copied to clipboard

Support refreshing oauth2 token

Open Tomen opened this issue 10 years ago • 11 comments

https://github.com/reddit/reddit/wiki/OAuth2#refreshing-the-token states that the token hast to be refreshed every hour by adding duration=permanent to the authorization request. I suppose this just has to be added here: https://github.com/stevenroose/dart-reddit/blob/master/lib/src/reddit.dart#L135-L138

Tomen avatar Aug 20 '15 21:08 Tomen

Thanks to point to the references, I will look at it tomorrow! On Aug 20, 2015 11:13 PM, "Tommi Enenkel" [email protected] wrote:

https://github.com/reddit/reddit/wiki/OAuth2#refreshing-the-token states that the token hast to be refreshed every hour by adding duration=permanent to the authorization request. I suppose this just has to be added here: https://github.com/stevenroose/dart-reddit/blob/master/lib/src/reddit.dart#L135-L138

— Reply to this email directly or view it on GitHub https://github.com/stevenroose/dart-reddit/issues/4.

stevenroose avatar Aug 20 '15 22:08 stevenroose

I noticed that the Dart oauth2 package should do token refreshing automatically. What kind of problem are you experiencing?

stevenroose avatar Aug 21 '15 16:08 stevenroose

I added the duration=permanent parameter. Can you confirm if it works now? Then I'll push it to Pub..

stevenroose avatar Aug 21 '15 16:08 stevenroose

Hey, awesome! I will look at it in the next few days and come back to you. Kind regards!

Tomen avatar Aug 25 '15 20:08 Tomen

@stevenroose Hey, i just checked it over night and i made a mistake. There is a chapter on application only oauth2 here: https://github.com/reddit/reddit/wiki/OAuth2#application-only-oauth

It states that applications never get a refresh token. It does not state why. So it looks to me as if you always had to get a fresh token (either once an hour or before every request).

So it seems as this is not fixable.

Tomen avatar Aug 27 '15 05:08 Tomen

@Tomen The library keeps the credentials anyways, so it can keep the expiration date and manually reauthenticate when a request is made after the token expires.

Should work, that is kindof how the oauth2 package does it, only they use the official refresh token mechanism.

Will try to look at this tomorrow or perhaps this evening.

stevenroose avatar Aug 27 '15 12:08 stevenroose

@Tomen Is this issue solved for you?

stevenroose avatar Dec 24 '15 00:12 stevenroose

i will take a look at it in the new year. i will report to you here then.

Greetings :)

Tomen avatar Dec 24 '15 21:12 Tomen

@Tomen & @stevenroose I was actually having an issue where I could not make authenticated calls at all. I realized that no authenticated calls (like get my subreddits) were in the examples. I tried to implement my own but I ran into a bunch of 403 errors everytime.

Do either of you have examples on calls that NEED oauth (instead of calls that work generically, like get posts)?

mrdjohnson avatar Apr 18 '18 14:04 mrdjohnson

I haven't used any, personally. So it's very well possible they are not supported, in which case contributions are more than welcome!

Perhaps you can check out some old issues, I remember people asking questions about oauth: https://github.com/stevenroose/dart-reddit/issues/1, https://github.com/stevenroose/dart-reddit/issues/2.

stevenroose avatar Apr 18 '18 14:04 stevenroose

Hmm, I'll look deeper into those and see if anything becomes clear, thanks Steven

mrdjohnson avatar Apr 18 '18 15:04 mrdjohnson