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

Discourse API Keys #6

Open
sajattack opened this issue Jul 29, 2018 · 18 comments
Open

Discourse API Keys #6

sajattack opened this issue Jul 29, 2018 · 18 comments

Comments

@sajattack
Copy link

Hey, just wanted to let you know discourse actually does support API keys for non-admins, it's just really poorly documented. There's some documentation here and here and some code here.

@mre
Copy link
Member

mre commented Jul 29, 2018

Oh wow, that's great news. 😄
The second link mentions that write tokens need to be unlocked by the admins. Can you confirm that?
Would mostly be interested in announcing new episodes of "Hello Rust" on the Rust forum. Have you tried that, perhaps? (Was just thinking because your code is also written in Rust)

@sajattack
Copy link
Author

Yeah I think I successfully posted to the "What are you working on this week" thread with it if I recall correctly.

@mre
Copy link
Member

mre commented Jul 30, 2018

uh! that's cool. Will give it a shot if I find some time. 👍

@sajattack
Copy link
Author

Yeah I just made another test post with it and it worked.

@sajattack
Copy link
Author

I think you have to strip the %0A's

@sajattack
Copy link
Author

sajattack commented Jul 30, 2018

Actually, I just clicked the URL and it loaded up for me. Maybe it was a temporary outage or you need to be logged in in the browser?

@mre
Copy link
Member

mre commented Jul 31, 2018

16 hours in, second link still dead... 😕

@mre
Copy link
Member

mre commented Aug 1, 2018

@sajattack, does the second link that I posted work for you? On my machine it doesn't while the first one works now.

@sajattack
Copy link
Author

No it doesn't. I didn't mean that you should remove all the URL encoding.

@mre
Copy link
Member

mre commented Aug 1, 2018

Oh. You're right. Funnily I was just rerunning the tool and then pasting the result here.
I could swear that I copied the link over verbatim but yeah, it works now. 😄

@mre
Copy link
Member

mre commented Aug 1, 2018

Thanks so far. 👍
I guess the next step would be to register the app as a URI handler for discourse://auth_redirect as you did here.
Would like to do that cross-platform (Mac/Linux). Would be cool to have a separate crate for that, but I guess that's out of the scope for now.
Will do that when I find some time (or you'd like to do it, which would also be awesome, of course).

@mre
Copy link
Member

mre commented Aug 1, 2018

Whelp, turns out there's https://github.com/maidsafe/system_uri, which we could use. 🎉

@sajattack
Copy link
Author

Nifty.

@mre
Copy link
Member

mre commented Aug 3, 2018

One question: does the authentication redirect really need to point to a discourse:// URL?
Was searching for this information but couldn't find it.

I'm asking because the system uri handler is quite tricky to get right - especially across platforms. https://github.com/maidsafe/system_uri helps, but one would still have to wrap hello into an app on Mac for example.
If we could use a simple http:// URL as an authentication redirect, things might become a little easier. In this case we could just spawn a little local webserver, open the generated auth link in a normal webbrowser and wait until the user signs in. Then the browser would get redirected to our little webserver which prints the auth token.
Semi-automatic, but easier to set up and doesn't modify the system's uri handlers.

What do you think?

@M3t0r and me were experimenting with this, but we didn't get it to work. See #7 for the current status.

@sajattack
Copy link
Author

sajattack commented Aug 3, 2018

The discourse:// URI is allowed by default. Other redirects have to be enabled by server admins.

"there is a site setting that lists where the redirect is allowed to go."
https://meta.discourse.org/t/generating-user-api-keys-with-rest-api/61916/19

@mre
Copy link
Member

mre commented Aug 3, 2018

Ah okay. That's unfortunate. Then I guess we'll have to go the hard way...
Thanks for the info! 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants