Code Monkey home page Code Monkey logo

Comments (9)

junyer avatar junyer commented on May 21, 2024

The only complication is that some of the emails are generated by overnight (eg batch) processes, so we can't use a redirect_uri ever.

Is it not "just" a case of obtaining a refresh token once and then providing that to whatever needs to use it?

I've found examples that work with IMAP (like this one) but nothing that works with SMTP that can be navigated completely via an API without any human intervention.

It's unclear where you were looking? In this repository, there's Java code and Python code that uses both IMAP and SMTP as well as Go code that uses SMTP.

from gmail-oauth2-tools.

murraycollingwood avatar murraycollingwood commented on May 21, 2024

from gmail-oauth2-tools.

junyer avatar junyer commented on May 21, 2024

In this example (https://oauth2-client.thephpleague.com/usage/) we retrieve
a provider using an API call that requires a "redirect_url". I couldn't
find any examples where this wasn't the case.

As per https://developers.google.com/identity/protocols/oauth2/resources/oob-migration, Google no longer supports the use of the OAuth2 OOB flow, so a redirect URI will always be required. However, https://github.com/thephpleague/oauth2-google does cover obtaining a refresh token once and subsequently exchanging it as needed for an access token, at which point the redirect URI shouldn't be involved. I'm completely unfamiliar with the PHP ecosystem, alas, so I don't have recommendations regarding SMTP libraries that support OAuth2.

from gmail-oauth2-tools.

murraycollingwood avatar murraycollingwood commented on May 21, 2024

from gmail-oauth2-tools.

junyer avatar junyer commented on May 21, 2024

'access_type' => "offline",
'redirect_uri' => "https://sobs.com.au/ui/xoauth2config.php?schoolid=15"

Those keys should be accessType and redirectUri, respectively, I believe?

Do you have any pointers as to where I should be looking?
Are there any debug options with the Google library?

Sorry, I know nothing about https://github.com/thephpleague/oauth2-google beyond what I saw in their README.md file. (And the only reason I know of it is because you had linked to their documentation previously.) I suggest asking for some help over on their issue tracker? I note that @shadowhand landed a few commits yesterday, so it's evidently still actively maintained. :)

from gmail-oauth2-tools.

murraycollingwood avatar murraycollingwood commented on May 21, 2024

from gmail-oauth2-tools.

junyer avatar junyer commented on May 21, 2024

The expiry isn't clear, is it an expiry for the accessToken or the
refreshToken or both? Does the refreshToken actually expire???

A refresh token doesn't expire (AFAIK) whereas an access token does expire. The refresh token will be revoked, I think, when either the user's password is changed or the application's access is removed.

I ran it again and the second time I only received an accessToken, no
refreshToken. Are there some rules around issuing refreshTokens???

I'm not sure, TBH, but setting prompt to consent in addition to setting accessType to offline may or may not help here.

from gmail-oauth2-tools.

murraycollingwood avatar murraycollingwood commented on May 21, 2024

from gmail-oauth2-tools.

junyer avatar junyer commented on May 21, 2024

You're welcome. Glad to help. :)

from gmail-oauth2-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.