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

Invalid_grant AADSTS9002313: Invalid request.Request is malformed or invalid #850

Closed
decomplexity opened this issue Jul 26, 2020 · 1 comment

Comments

@decomplexity
Copy link

I am trying to get PHPMailer to authenticate with SMTP AUTH using Oauth2.

I am using the thephpleague’s OAuth2 and thenetworg’s Azure provider via MSFT’s V2 authorisation and token endpoints (the StevenMaguire provider previously used for Live Mail and so on is out of date).
My MSFT tenant has SMTP AUTH enabled (MSFT is disabling it on new tenants).
My Composer JSON requires the following versions: phpmailer/phpmailer": "~6.1" and "thenetworg/oauth2-azure": "1.4.2"
I am running PHP 5.6.

So…
get_auth_token works fine and the ‘code=’ refresh token that is part of the returned URL is cut and pasted to my authorization code module (the code with ‘new Azure()’ and ‘new Provider()’).

But invoking my base module gives Fatal error: Uncaught exception 'League\OAuth2\Client\Provider\Exception\IdentityProviderException' with message 'invalid_grant AADSTS9002313: Invalid request. Request is malformed or invalid.
Trace ID: 96c59fae-0904-4a68-910f-dd1628404000 Correlation ID: 147e4826-54eb-43d0-97d3-7c12fb4e7435 Timestamp: 2020-07-26 18:25:38Z'.

Checking in AbstractProvider.php’s getAccessToken method, the $params array parameters (client_id, client_secret and redirect_uri) and the $options parameter (refresh_token) all have the values assigned in my authorization code module so nothing appears to have got lost on the way.

The refresh token is 750 characters:

  • a single-character prefix (0)
  • a dot
  • a 51 character payload
  • a dot
  • a 696 character ‘signature area’

Whether these are sensible I know not, since the content of refresh tokens is (by design) known only to the issuer.

Any suggestions appreciated on how to proceed.

[Since the error is flagged from a thephpleague module but the provider is thenetworg’s Azure, I am posting here with a shadow post for the thenetworg’s Azure]

@ramsey
Copy link
Contributor

ramsey commented Oct 28, 2020

Closing, since this is being handled over at TheNetworg/oauth2-azure#114

@ramsey ramsey closed this as completed Oct 28, 2020
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