vartanbeno / go-reddit

Go library for accessing the Reddit API.
Other
306 stars 84 forks source link

401 Unauthorized #2

Closed neumachen closed 3 years ago

neumachen commented 4 years ago

I can't seem to get a basic auth going using Client ID, Client Secret, Username and Password. Any ideas why? I verified and I'm 100% sure I'm setting the right values.

vartanbeno commented 4 years ago

Hey! Thanks for opening the issue. Can you provide a code snippet so we can check what's wrong?

Don't forget to censor your credentials 😛

ashwinkey04 commented 3 years ago

Hey @vartanbeno! I am getting a 400 Bad request while trying out one of your sample programs to upvote a post. It'd be great if you can look into this and help me out :)

package main

import (
    "context"
    "fmt"
    "github.com/vartanbeno/go-reddit/reddit"
)

func main() {
    withCredentials := reddit.WithCredentials("2_TP*******W9w", "pgJBp77KS************albdwY", "ashwin_apk", "*********")
    client, _ := reddit.NewClient(withCredentials)
    _, err := client.Post.Upvote(context.Background(), "t3_33hw9x")
    if err != nil {
        fmt.Println(err)
        return
    }
}
vartanbeno commented 3 years ago

Hey @ashwinkey04. I'm getting that error as well for that specific post (t3_33hw9x). When I look at the post here, I see that it's from 5 years ago and archived, meaning you won't be able to vote or comment on it. That might be the reason why.

ashwinkey04 commented 3 years ago

@vartanbeno Thanks a ton! I hope I learn to use Reddit properly someday :sweat_smile: