CURL.SetOptionXOAuth2Bearer
---------------------------

The XOAUTH2 bearer token.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [8.2](newinversion82.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.SetOptionXOAuth2Bearer"; curl; Value ) 

**MBS**( **"CURL.SetOptionXOAuth2Bearer";** /\* The XOAUTH2 bearer token. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Value**) /\* The option value. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| curl | The CURL session handle. | $curl |
| Value | The option value. |  |

### Result

Returns OK or error.

### Description

The XOAUTH2 bearer token.  
For open authentication used with web services.  
No Bearer prefix please.  
  
If used, please don't call [CURL.SetOptionUserName](CURLSetOptionUserName.md) and [CURL.SetOptionPassword](CURLSetOptionPassword.md) as that would overwrite the token.  
  
Use e.g. with google mail.  
See also [XOAUTH2\_BEARER](https://curl.haxx.se/libcurl/c/CURLOPT_XOAUTH2_BEARER.html) option in CURL manual.

### Examples

Setup oAuth for SMTP with user name, bearer and no password:

 Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPUserName](SendMailSetSMTPUserName.md)"; $EmailID ; "test@gmail.com") \]   
Set Variable \[ $r ; Value: MBS ("[SendMail.SetSMTPPassword](SendMailSetSMTPPassword.md)"; $EmailID ; "" // empty ) \]   
\# ...   
Set Variable \[ $r ; Value: MBS ("CURL.SetOptionXOAuth2Bearer"; $curl ; "dXNlcj1zb21...") \]  
Setup IMAP for Office 365:

 Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "imaps://outlook.office365.com/INBOX") \]   
\# your oAuth token   
Set Variable \[ $r ; Value: MBS ("CURL.SetOptionXOAuth2Bearer"; $curl ; "eyJ0eXAiOi...") \]  
\# no password needed! Just username:   
Set Variable \[ $r ; Value: MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; "test@outlook.com") \]  
### See also

- [CURL.SetOptionAutoReferer](CURLSetOptionAutoReferer.md)
- [CURL.SetOptionPassword](CURLSetOptionPassword.md)
- [CURL.SetOptionUploadFlags](CURLSetOptionUploadFlags.md)
- [CURL.SetOptionURL](CURLSetOptionURL.md)
- [CURL.SetOptionUserName](CURLSetOptionUserName.md)
- [SendMail.SetSMTPPassword](SendMailSetSMTPPassword.md)
- [SendMail.SetSMTPUserName](SendMailSetSMTPUserName.md)

### Example Databases

- [CURL/Email/GMail oAuth SMTP](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/GMail%20oAuth%20SMTP.shtml#5ScriptAnchor_)
- [CURL/Email/IMAP Email List](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email%20List.shtml#1ScriptAnchor_)
- [CURL/Email/IMAP Email Upload](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email%20Upload.shtml#1ScriptAnchor_)
- [CURL/Email/IMAP Email](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email.shtml#11ScriptAnchor_)
- [CURL/Email/List IMAP folders](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/List%20IMAP%20folders.shtml#1ScriptAnchor_)
- [CURL/Email/Office 365 oAuth SMTP](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Office%20365%20oAuth%20SMTP.shtml#5ScriptAnchor_)
- [CURL/WebServices/ebay webservice/ebay Webservice](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/ebay%20webservice/ebay%20Webservice.shtml#2ScriptAnchor_)

### Blog Entries

- [IMAP Upload Flags](https://www.mbsplugins.de/archive/2025-06-17/IMAP_Upload_Flags/monkeybreadsoftware_blog_filemaker)
- [Using Gmail with oAuth2 for SMTP with MBS Plugin](https://www.mbsplugins.de/archive/2025-05-08/Using_Gmail_with_oAuth2_for_SM/monkeybreadsoftware_blog_filemaker)
- [More follow up on oAuth for Office 365](https://www.mbsplugins.de/archive/2023-02-11/More_follow_up_on_oAuth_for_Of/monkeybreadsoftware_blog_filemaker)
- [SMTP with OAuth for Office 365 in FileMaker](https://www.mbsplugins.de/archive/2022-11-22/SMTP_with_OAuth_for_Office_365/monkeybreadsoftware_blog_filemaker)
- [GMail for emails with MBS Plugin](https://www.mbsplugins.de/archive/2021-04-18/GMail_for_emails_with_MBS_Plug/monkeybreadsoftware_blog_filemaker)

Created 15th April 2018 , last changed 7th September 2025

  
[CURL.SetOptionWildCardMatch](CURLSetOptionWildCardMatch.md) - [CURL.SetProgressEvaluate](CURLSetProgressEvaluate.md)

[HTML Version](CURLSetOptionXOAuth2Bearer.shtml)