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

phpmailer token #213

Open
yanndupont opened this issue Jul 4, 2024 · 3 comments
Open

phpmailer token #213

yanndupont opened this issue Jul 4, 2024 · 3 comments

Comments

@yanndupont
Copy link

Hello is there someone making it works with the auth token and phpmailer?

I tried to use the refrehed token but phpmailer return CLIENT: 535 5.7.3 Authentication unsuccessful
Using graph api is great but i struggle with phpmailer.

$mail->setOAuth(
new OAuth(
[
'provider' => $provider,
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'refreshToken' => $refreshToken,
'userName' => $email,
]
)
);

i also tried to set url of the api and version without more success
$provider->urlAPI = 'https://graph.microsoft.com/';
$provider->API_VERSION = '1.0';

Any help is welcome,
Thanks

@decomplexity
Copy link

The two usual reasons for authentication failure are bad token and wrong scope:

  • the token you are giving to PHPMailer as a refresh token isn't a refresh token (perhaps it is an authentication token)
  • the scope you are specifying gives an AUD claim of Graph: see "Microsoft OAuth2 SMTP issues" in the PHPMailer WiKi

@yanndupont
Copy link
Author

Hi

The two usual reasons for authentication failure are bad token and wrong scope:

  • the token you are giving to PHPMailer as a refresh token isn't a refresh token (perhaps it is an authentication token)
  • the scope you are specifying gives an AUD claim of Graph: see "Microsoft OAuth2 SMTP issues" in the PHPMailer WiKi

Hi,
i use the scope https://outlook.office.com/SMTP.Send when calling the provider
'scopes' => ['openid profile email offline_access https://outlook.office.com/SMTP.Send']
the token is indeed an authentication one.
The goal is to call one time (and not twice) the url back to identify, grab user details and use smtp.

@decomplexity
Copy link

If you decode the access token with e.g. jwt.ms (you might need to debase64 decode the token first using https://www.base64decode.org/ ), please let us have the AUD claim. To see the access token, enable SMTP debugging using (in your PHPMailer script) $this->mail->SMTPDebug = SMTP::DEBUG_LOWLEVEL; It will be displayed as a long character string just before your authentication fails,

Note that you cannot decode a refresh token

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