Replies: 2 comments 5 replies
-
Unfortunately, I don't have access to test OAuth authentication myself. It's contributed code but I've seen others have success using it. Your code looks correct, which hints at the auth tokens being wrong. Do you have any other means to test them against EWS? It's possible that the tokens are correct, but are not allowed to be used for EWS. |
Beta Was this translation helpful? Give feedback.
5 replies
-
I got it working with this open-source RPA (Robocorp) robot: class OAuth2Creds(OAuth2AuthorizationCodeCredentials):
"""OAuth2 auth code flow credentials wrapper supporting token state on refresh."""
def __init__(self, *args, on_token_refresh: Callable, **kwargs):
super().__init__(*args, **kwargs)
# Additional behaviour to trigger during token refresh (when it expires), like
# saving the newly generated structure in the Vault.
self._on_token_refresh = on_token_refresh
def on_token_auto_refreshed(self, access_token: OAuth2Token):
super().on_token_auto_refreshed(access_token)
self._on_token_refresh(access_token)
self.credentials = OAuth2Creds(
on_token_refresh=self.on_token_refresh,
identity=Identity(upn=username),
client_id=client_id,
client_secret=client_secret,
# Contains at least a non-expired access token or non-revoked refresh
# one. (otherwise an authorization code should be present inside)
access_token=OAuth2Token(params=token) if token else None,
)
self.config = Configuration(
server=server,
credentials=self.credentials,
# Automatically detects authentication type based on the provided
# `credentials` object. (when not using OAuth2)
auth_type=OAUTH2 if is_oauth else None,
) Make sure you:
and you should get it working. (as ready to test from the Portal example) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Erik,
My id is in shared mailbox(cloud) & have client,tenant,secrert id. How to perform OAuth2 authentication to access my id.
Tried below code showing "Unauthorized Error: Invalid credentials for https://outlook.office.com/EWS/Exchange.asmx" .
could u please help on this.
Beta Was this translation helpful? Give feedback.
All reactions