Progress is being made rapidly on StackMode, an Emacs client for StackExchange, and now we need to be able to make authenticated requests to the API for continued testing. (The 300-request limit is starting to limit how much testing I can do in a day.)
Disclaimer: I know very little about web development; it's one of the areas I'm working on professionally. Please excuse me if I misuse any terms and feel free to correct me in the comments. Thanks!
The StackExchange API uses OAuth 2.0 authentication. Since this is a local client application with client authorization. I have the following pieces of information provided to me by StackExchange:
- Client ID
- Client Secret (mustn't share, so it shouldn't be necessary in this flow)
- Key
- Description (not OAuth related)
- OAuth Domain
- Application Website (not OAuth related)
- Application Icon (not OAuth related)
- Stack Apps Post (not OAuth related)
with the following extra pieces of information:
- Client Side Flow Is Enabled
- Desktop OAuth Redirect Uri Is Enabled
In order to keep any answer both general and explicit, you can use my-client-id
(etc.) for values. Actual values—those I think I'm OK to share, are available on GitHub.
I've been researching this for half the day, but I'm not very much closer to a solution than when I started. The closest I've gotten is this little snippet of code:
(require 'oauth2) ; available via GNU ELPA
(defconst stack-auth-token
(make-oauth2-token
:client-id stack-auth--client-id
:client-secret stack-auth--key))
;; this doesn't use the above, but it does open an auth page on SE
(oauth2-auth-and-store
"https://stackexchange.com/oauth/dialog"
nil nil
stack-auth--client-id
stack-auth--key
"https://stackexchange.com/oauth/login_success")
The only things I have to offer an OAuth2 request (from above) are apparently
- Client ID
- Key
- OAuth Domain
How can I implement this flow in Elisp?
Current 'Flow'
- Execute
oauth2-auth-and-store
with proper variables set. Opens
- Click "Approve"
Opens
with this URL
The application is successfully added
But I have no code to provide
oauth2
In addition to answers, PRs are also welcome, of course.