Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement Reddit [Possible Solution] #856

Closed
1 of 5 tasks
afoyer opened this issue Nov 16, 2020 · 8 comments · Fixed by #1094
Closed
1 of 5 tasks

How to implement Reddit [Possible Solution] #856

afoyer opened this issue Nov 16, 2020 · 8 comments · Fixed by #1094
Labels
enhancement New feature or request providers question Ask how to do something or how something works

Comments

@afoyer
Copy link
Contributor

afoyer commented Nov 16, 2020

Your question

Do any of you know how to make Reddit work?

What are you trying to do

I am trying to authenticate but once I authorize get_access_token fails and returns a 401 error

Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.

  • Found the documentation helpful
  • Found documentation but was incomplete
  • Could not find relevant documentation
  • Found the example project helpful
  • Did not find the example project helpful
@afoyer afoyer added the question Ask how to do something or how something works label Nov 16, 2020
@afoyer
Copy link
Contributor Author

afoyer commented Nov 17, 2020

After looking into it I may have found the problem.
In /server/lib/oauth/callback.js the authorization header was not creating a clientID:password pair then encoding it in base64

I added this in the meantime (bandaid fix I know) and I can now access the token and my profile (thanks to @LoriKarikari 's premade provider)! This is only a quick fix so maybe there is already a base64 encoder somewhere in there that I did not notice.

if (provider.id == 'reddit') {
      headers.Authorization = 'Basic ' + Buffer(provider.clientId + ":" + provider.clientSecret).toString('base64');
    }`

This works without issues with Spotify or Twitch when I was testing, but I haven't tried more providers.

@afoyer afoyer changed the title How to implement Reddit How to implement Reddit [Possible Solution] Nov 17, 2020
@LoriKarikari
Copy link
Contributor

@afoyer thanks for looking into this! We were having this issue with Reddit but also some other providers (can't remember them by heart). We can test if this fix also works for the other providers and implement this @iaincollins?

@iaincollins iaincollins added the enhancement New feature or request label Dec 4, 2020
@balazsorban44
Copy link
Member

@LoriKarikari

It looks like this has been added already:

if (provider.id === 'reddit') {
headers.Authorization = 'Basic ' + Buffer.from((provider.clientId + ':' + provider.clientSecret)).toString('base64')
}

Is the Reddit provider https://github.com/nextauthjs/next-auth/blob/canary/src/providers/reddit.js
still unfinished? ( The profile callback is commented out and there is a comment at the top

// Logging in works but trying to retrieve the profile results in 401 unauthorized

)

There is no documentation page for it though, and not mentioned anywhere in the docs page. Other than that, if someone can confirm it work, we could close this issue?

@afoyer
Copy link
Contributor Author

afoyer commented Jan 12, 2021

@balazsorban44 I am about to create a reddit.md file for the doc page. The last time I checked (which was two months ago) everything seemed to be working including what was indicated in the commented profile section. I can also uncomment the callback and remove the top comment since the solution I provided was an answer to that.

@balazsorban44
Copy link
Member

Awesome news! Could you please check if 3.2.0-canary-22still works please? 😊 made some internal changes, but hopefully nothing is broken.

@afoyer
Copy link
Contributor Author

afoyer commented Jan 12, 2021

#1094 I got it to work but with a hack.
I had to add the Reddit provider to the index.js file in providers. I can't seem to find it on Github but it's there, somewhere.
Do you know why there's an index.js file when installing through npm but not in the repo (in src/providers)?

@github-actions
Copy link

🎉 This issue has been resolved in version 3.2.0-canary.23 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Feb 1, 2021

🎉 This issue has been resolved in version 3.3.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request providers question Ask how to do something or how something works
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants