-
Notifications
You must be signed in to change notification settings - Fork 47
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
Retrieving OAuth 2.0 tokens via Out Of Band redirect_uri
is deprecated
#191
Comments
Hi, I'll try to get to this once I fix #160 |
For what it's worth, I've been writing and debugging an OAuth2 library using a (very simple) HTTP server in Emacs and Aio. Here it is https://github.com/rhaps0dy/emacs-oauth2-auto/ I think the interface for it is pretty good: a single function gets you an updated and refreshed token. I've been able to use it for (defun org-gcal--get-access-token ()
(oauth2-auto-access-token-sync "[email protected]" 'google)) then the oauth2 credentials for the apps that are at As a bonus, it supports multiple accounts! PS: Thank you very much telotortium for fixing and merging PR 192 !! (not linking on purpose) |
Do you think your web-based OAuth2 functionality could be merged in to this existing emacs oauth2 package? It has the same problem where it uses the If your feature was merged into emacs' |
Probably yes. It would replace almost all of the code, and I'm not sure the interface for this library is fully compatible with the functionality of How do I even contribute to The part about having predefined authentication backends scratches my own itch and I'll keep it though. It's probably also good to keep it for other users; it's non-trivial and annoying to fill out all the parameters of |
That would be super cool!
It looks like the Probably your best bet would be to try emailing the maintainer Julien Danjou [email protected] and see how he'd like to go about merging your PR. The library itself has been around a while, but it looks like Julien last commited to the repo in 2021 so it appears stable and actively maintained.
FWIW I think keeping the |
hi, I am also facing the problem with OAuth2 authentication with my 'app' and I tried to use @rhaps0dy 's package; unfortunately, I am getting 'Something went wrong' right after I choose my GMail user: (the Google API's app is running in Testing status, with External user type, with my Google used added to Test Users; in Credentials section I can see one created, with Client ID and Secret that I use). Any help would be greatly appreciated! |
@lwiechec oh no! What's your config like? Are you using my pasted function above to substitute |
@rhaps0dy thanks for reaching out! The setup I tried: (require 'oauth2-auto)
(require 'plstore)
(setq plstore-encrypt-to "[email protected]")
(setq oauth2-auto-google-client-id "[REDACTED]"
oauth2-auto-google-client-secret "[REDACTED]")
(defun org-gcal--get-access-token ()
(oauth2-auto-access-token-sync "[email protected]" 'google))
;;; other org-gcal-fetch stuff
(org-gcal-fetch) PS: when I click on 'Next' button in the screenshot above, I am getting this: |
hi again, thanks for help! when I print the URL, I am getting:
which looks similar (no unencoded '#' anywhere). I have also enabled the GMail permission in the app. It still complains about the request being malformed: |
I'm very confused, your URL with my client ID and email works perfectly. Here's a list of possible problems: https://support.google.com/websearch/thread/95249301/how-do-i-fix-the-server-cannot-process-the-request-because-it-is-malformed-it-should-not-be-retried?hl=en . Maybe try pasting the URL in a private window of your browser, or clearing the cookies? Is your Client ID of the form |
thanks for help - it seems that this was indeed my browser's fault. Running it in private window of Firefox made it authenticate and receive the token. Thanks a million! I am still not able to sync the calendar but it's because of something else: there seem to be problem with
...which indicates some issue in |
Great! I suggest you open a new issue with that, and give more information about:
etc. Just so people can reproduce your bug. |
Update: I have reported this bug to the Emacs bug tracker (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54913) and patches are welcome, so at some point in the next month I'll submit a patch for |
...after enabling verbose logging from After setting the correct CA bundle via After switching back to 'silent' mode of Thanks again @rhaps0dy for help! |
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
@rhaps0dy I've made #200 to use oauth2-auto for org-gcal's OAuth2 authentication. Could you add oauth2-auto to Melpa? |
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
Is there a way to authorize Google Calendar and org-gcal. I followed the steps in the readme file and ended up on this thread. I checked out emacs-oauth2-auto but that was a mote point as his readme is not really clear. Is there an updated document on how to install org-gcal |
Is this still an issue? Is it possible to use gcal to sync with org mode? If not, are there any workarounds? |
Note that this is a quick fix so it may have some bugs. Please use with your own risk.
At least for me, the old API is still working. I included org-gcal as a testing app before October 2022, though. Once #200 is merged, I can test it further. Best. |
This allows switching from the deprecated OOB flow <https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#disallowed-oob>, fixing <kidd#191>. As a side effect, oauth2-auto makes it straightforward to support multiple accounts (see <kidd#199>), although this PR doesn't by itself enable that.
Fantastic, thank you! 😀 |
Thanks! |
I'm not very well versed in OAuth 2.0, but it looks like Google has changed how part of their OAuth 2.0 flow works. We'll need to update how we obtain & refresh authorization tokens in order to keep functioning.
How this impacts org-gcal
Since
redirect_uri
scheme to get authentication tokens, and,This is already the case for any new OAuth 2.0 credentials you create (so don't delete them!). Existing credentials will continue to work through October 2022, at which point they will also cease to work.
Details
Here's my understanding of the situation. I think this correctly captures the major details, but my OAuth 2.0 terminology might not be quite right:
redirect_uri = urn:ietf:wg:oauth:2.0:oob
. This means thatorg-gcal-request-authorization
opens a browser window to an OAuth 2.0 flow that ends with a token code that can be pasted back into an emacs inputprompt
redirect_uri
fail with an invalid request error. Existing OAuth 2.0 credentials will continue to work with the oobredirect_uri
scheme until the end of October 2022, at which point they will also cease working.localhost
redirect_uri
scheme. This involves:XXXX
prior to browsing to the OAuth 2.0 endpointredirect_uri=http://localhost:XXXX
localhost:XXXX
with the OAuth 2.0 token passed as a URL query parametersFixing this
I poked around for a few hours tonight at trying to fix this. My idea so far is rework
org-gcal-request-authorization
to start an http server, then parse the response out after the redirect and continue as normal.We can create the server using simple-httpd and manage the callbacks using aio (which is what @telotortium settled on using for the other async code in #160)
This could look something like this - note that all "Desktop Application" OAuth 2.0 credentials created support the
localhost
redirect_uri
.Then
(aio-with-async (org-gcal-request-authorization))
returns a promise that resolves to the OAuth 2.0 code.
I'm happy to keep working on this but wouldn't mind suggestions from others on how to implement it. In particular, this
aio-defun
would need to interface with thedeferred
code inorg-gcal-request-token
. Maybe this means that this issue should be fixed on top of #160?Possibly related issues: #97 #171 #173
The text was updated successfully, but these errors were encountered: