Getting an API key

The UI to do that is very poor, though. There are three visible on-screen controls - a left-pointing double chevron (with no label but a tooltip that says “hide preview”), a strange two-headed arrow (again no text, tooltip “enter fullscreen composer”). The third control just makes the reply disappear for no apparent reason. Hilariously, there is no reply button after clicking the strange two-headed arrow, so you have to click another (unlabelled) button to get that back.

There is one sane reply UI though - reply by email (if you turn on emails from the site and use it like a mailing list).

Well, the good thing is that there are options for everyone: tweakable web UI, RSS feeds, API, email… :wink:

2 Likes

Well this is interesting.

I used the Python script that’s linked in @nukeador 's second mentioned URL the generate a User-API-Key with the other account - and NOW I see “Apps” in the settings of that user where I could revoke said key, but I still don’t see the “Apps” setting under my “personal” user. Strange :slight_smile:

1 Like

From what I read, there is no way to get an API from the UI for users, that’s why someone created that script.

Good to know … Not that it was working when I called the endpoint (“you have no access to this resource, User API Key or Username incorrect”) but that’s a problem for future Kai.

This one worked for me: Generate user API key for Discourse / Robin van Boven | Observable

$ curl -X GET "https://community.openstreetmap.org/groups.json" -H "User-Api-Key: aabababababbabbabbabbabbbabbb832" 
{"groups":[{"id":42,"automatic":false,"name":"forums-governance","user_count":4,"mentionable_level":99,"messageable_level":99,"visibility_level":0,"primary_group":true,"title":"Forums governance team","grant_trust_level":4,"flair_url":"landmark","flair_bg_color":"EEE","flair_color":"666","bio_cooked":"<p>People who are helping with this forum governance. <a href=\"https://community.openstreetmap.org/t/which-governance-accountability-model-do-we-want-for-this-tool-who-and-how-should-decisions-being-made/220\">More info and discussion</a></p>","bio_excerpt":"People who are helping with this forum governance. <a href=\"https://community.openstreetmap.org/t/which-governance-accountability-model-do-we-want-for-this-tool-who-and-how-should-decisions-being-made/220\">More info and discussion</a>","public_admission":false,"public_exit":true,"allow_membership_requests":false,"full_name":"Forums governance team","default_notification_level":3,"membership_request_template":"","members_visibility_level":0,"can_see_members":true,"publish_read_state":false},{"id":2,"automatic":true,"name":"moderators","display_name":"Moderatoren","user_count":1,"mentionable_level":0,"messageable_level":99,"visibility_level":1,"primary_group":false,"title":null,"grant_trust_level":null,"flair_url":null,"flair_bg_color":null,"flair_color":null,"bio_cooked":null,"bio_excerpt":null,"public_admission":false,"public_exit":false,"allow_membership_requests":false,"full_name":null,"default_notification_level":2,"membership_request_template":null,"members_visibility_level":0,"can_see_members":true,"publish_read_state":false},{"id":56,"automatic":false,"name":"mods-argentina","user_count":3,"mentionable_level":99,"messageable_level":99,"visibility_level":
...

(User-Api-Key length matches the actual key length)

I have no idea how trustworthy the site is, though… :wink:

1 Like

@nukeador @Firefishy, the good @derFred was asking whether we can find a way to automatically post updates to the weeklyOSM team - a thread - as the API keys I can generate myself, albeit them not working properly as of right now, are read-only that wouldn’t help.

Would it be possible for any of you guys to create a write-access API Key to attach to a user that can post there?

Kai

1 Like

Uhm, I assumed the APi you got from the script had also write access.

@Firefishy do you know if this is possible or an admin needs to create a user one?

1 Like

Update OSM Software Watchlist gets updated automatically by @wambacher , maybe ask him how he posts updates…

2 Likes

ask him how he posts updates…

By hand :frowning:

thats why i need either an api-key or need to know how to post replies per e-mail.

asked for posting per e-mail but did not get any good answer.

Walter

I thought you did. Follow your own thread and post there to get an e-mail notification. Then answer to that per e-mail. Or is this not what you need?

It is possible to create a write enabled API key linked to a specific user. Let me know the user and I can create the key. Please also let me know best route to send it to you.

@Firefishy

My userid is “wambacher” and my e-mail is “wambacher@posteo.de

Regards
walter

After reading this thread, it’s still unclear for me how to get an API-Key. Could someone help with a cook recipe?

Did you plan to use the API Key for read only purposes (in which case you can request it on your own), or do you also want to create new posts using the API?

API-Key = “Read-Only”

That is exact my question.

Did try the site I posted on Getting an API key - #15 by mmd ? In step 1, you need to enter https://community.openstreetmap.org then follow along the steps 2-3.

After authorizing the call, you will see some key which you need to copy & paste back into the observablehq.com page.

2 Likes

Thanks … I struggled over the step to put the info back into the page. But now I was able to generate a (read-only) API-Key. This works for me (first test):

curl --request GET "https://community.openstreetmap.org/site.json" \
--header "User-Api-Key: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
--show-error \
--include

(real API-Key masked out with ‘a’)

1 Like

I tried to create an API key with all the tricks listed here, but eventually gave up as I could not get write permissions.

So I found the following solution for me: simply sending an email to the reply-to Address of each thread works just fine, if it is sufficient to comment on existing threads.

You find the mail_to which encodes your user and the thread in each of the notifications that you receive, just check the reply-to header.

Sample code in python to send emails:

try:
    server = smtplib.SMTP(self.mail_smtp_host, self.mail_smtp_port)
    server.ehlo()
    server.starttls()
    server.login(self.mail_user, self.mail_pw)
    server.sendmail(self.mail_from, self.mail_to, msg.as_string())
    server.close()
except:
    print("failed to send mail")
    traceback.print_exc()

The email must originate from the address your account uses in this forum, of course.

UPDATE: turns out the python SMTP library does not set a date header and discourse doesn’t like that. We’ll try to set the respective postfix flag in our next try

UPDATE UPDATE: That worked! :tada:

You need to ask an admin for an API key with write permissions…