How to authenticate with google smtp after receiving okta session token?

i programmatically login into okta and upon success i get a reponse:

{'expiresAt': '2024-04-23T02:23:12.000Z',
 'status': 'SUCCESS',
 'sessionToken': 'MY SESSION_TOKEN,
 '_embedded': {'user': {'id': 'MY_USER_ID',
   'passwordChanged': '2023-12-03T18:00:39.000Z',
   'profile': {'login': 'MY_OKTA_LOGIN',
    'firstName': 'FIRST NAME',
    'lastName': 'LAST NAME',
    'locale': 'en_US',
    'timeZone': 'America/Los_Angeles'}}},
 '_links': {'cancel': {'href': '',
   'hints': {'allow': ['POST']}}}}

Then i can hopefully somehow use the session token to login into gmail to send some email

 smtp = smtplib.SMTP('', 587)
    # smtp_server = smtplib.SMTP(server, port) # smtplib.SMTP_SSL('', 465)
    if use_tls:
    smtp.login(username, password)

what value should i pass for user name and password ?

To authenticate with Google SMTP after obtaining an Okta session token:

  1. Obtain the Okta session token by authenticating with Okta.
  2. Exchange the Okta token for an OAuth access token compatible with Google SMTP.
  3. Use the OAuth access token to authenticate with Google SMTP.
  4. Send emails using Google SMTP.

If you want to skip all these steps, contact with smtp server service providers like SMTPget, iDealSMTP, or SendGrid. They will do all these things for you.