Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4   10.5    Statistic    FMM    Blog  

CURL.SetupOAuth

Setups an OAuth signed transfer.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 8.3 Yes Yes Yes Yes Yes
MBS( "CURL.SetupOAuth"; curl; ConsumerKey; ConsumerSecret; AccessToken; AccessTokenSecret; HTTPVerb; URL { ; Parameters; Headers; Datas; Nonce; Timestamp; HMAC; Verifier; Realm } )   More

Parameters

Parameter Description Example Flags
curl The CURL session handle. $curl
ConsumerKey The oauth consumer key. "xvz1evFS4wEEPTGEFPHBog"
ConsumerSecret The oauth consumer secret. "kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw"
AccessToken The oauth access token.
Can be empty if not yet known.
"370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb"
AccessTokenSecret The oauth access token secret.
Can be empty if not yet known.
"LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE"
HTTPVerb The HTTP verb.
e.g. POST, PUT, GET, DELETE.
Default if empty is GET.
"POST"
URL The URL to query without parameters. "https://api.twitter.com/1.1/statuses/update.json"
Parameters List of parameters.
Can be empty.
Please pass list with newline as delimiter.
values should be URL encoded already.
"include_entities=true" Optional
Headers List of additional header entries to include.
Can be empty.
We automatically set Authorization header.
"Accept: application/json¶Content-Type: application/json" Optional
Datas Data value list for POST. "status=Hello¶others=123" Optional
Nonce The nonce value.
If empty, we generate it automatically for you.
"kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg" Optional
Timestamp The timestamp to use for signature.
If empty, we query current timestamp (same as you calling Time.UnixTimeStamp)
1318622958 Optional
HMAC Which HMAC algorithm to use.
Can be HMAC-SHA512, HMAC-SHA256 or HMAC-SHA1.
Default is HMAC-SHA1 if parameter is missing or empty.
"HMAC-SHA1" Optional
Verifier The verifier. Usually an ID shown on a website after login to the service and authorization of an app. "3456789" Optional
Realm Available in MBS FileMaker Plugin 10.5 or newer.
The realm value, e.g. for account name.
Pass empty if not used.
Optional

Result

Returns OK or error.

Description

Setups an OAuth signed transfer.
The plugin calculates the signature and adds headers for authorization to the CURL handle.
Sets URL with parameters and optionally data values for POST.

Examples

Setup OAuth query for Twitter:

# global settings (Sample entries from Twitter documentation)
# https://developer.twitter.com/en/docs/basics/authentication/guides/creating-a-signature.html
#
Set Variable [ $ConsumerKey ; Value: "xvz1evFS4wEEPTGEFPHBog" ]
Set Variable [ $ConsumerSecret ; Value: "kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw" ]
Set Variable [ $AccessToken ; Value: "370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb" ]
Set Variable [ $AccessTokenSecret ; Value: "LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE" ]
Set Variable [ $nonce ; Value: "kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg" ]
Set Variable [ $TimeStamp ; Value: "1318622958" ]
#
Set Variable [ $URL ; Value: "https://api.twitter.com/1.1/statuses/update.json" ]
Set Variable [ $Method ; Value: "POST" ]
#
Set Variable [ $Parameters ; Value: "include_entities=true" ]
Set Variable [ $Headers ; Value: "" ]
Set Variable [ $Data ; Value: "status=Hello%20Ladies%20%2B%20Gentlemen%2C%20a%20signed%20OAuth%20request%21" ]
#
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetupOAuth"; $curl; $ConsumerKey; $ConsumerSecret; $AccessToken; $AccessTokenSecret; $Method; $URL; $Parameters; $Headers; $Data; $Nonce; $Timestamp) ]
# Perform...
#
# signature must be hCtSmYh+iHYCEqBWrE7C7hYmtUk=
#
# Cleanup
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]

Query magento web service:

# globale einstellungen für Zugang
Set Variable [ $ConsumerKey ; Value: "xxx" ]
Set Variable [ $ConsumerSecret ; Value: "xxx" ]
Set Variable [ $AccessToken ; Value: "xxx" ]
Set Variable [ $AccessTokenSecret ; Value: "xxx" ]
#
# Für diesen Request GET mit der Customers URL
Set Variable [ $URL ; Value: "http://xxxx/index.php/rest/V1/customers/" & $customerID ]
Set Variable [ $Method ; Value: "GET" ]
# Optional parameters for filters
Set Variable [ $Parameters ; Value: "abc=hello¶test=world" ]
#
# Start new session
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetupOAuth"; $curl; $ConsumerKey; $ConsumerSecret; $AccessToken; $AccessTokenSecret; $Method; $URL; $Parameters; "") ]
# RUN now
Set Field [ CURL::Result ; MBS("CURL.Perform"; $curl) ]
# Check result
Set Field [ CURL::HTTP Response ; MBS("CURL.GetResponseCode"; $curl) ]
Set Field [ CURL::Customer Info ; MBS("CURL.GetResultAsText"; $curl; "UTF8") ]
Set Field [ CURL::debug ; MBS("CURL.GetDebugAsText"; $curl) ]
# Cleanup
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]

Update customers in magento:

Set Variable [ $ConsumerKey ; Value: "xxx" ]
Set Variable [ $ConsumerSecret ; Value: "xxx" ]
Set Variable [ $AccessToken ; Value: "xxx" ]
Set Variable [ $AccessTokenSecret ; Value: "xxx" ]
#
# PUT to this URL
Set Variable [ $URL ; Value: "http://m2.castinfo.im-labor.de/index.php/rest/V1/customers/" & CURL::customerID ]
Set Variable [ $Method ; Value: "PUT" ]
Set Variable [ $Content ; Value: MBS( "JSON.AddItemToObject"; "{}"; "customer"; CURL::Customer Info) ]
Set Variable [ $Parameters ; Value: "" ]
Set Variable [ $Headers ; Value: "Accept: application/json¶Content-Type: application/json" ]
#
#
# Start new session
Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetupOAuth"; $curl; $ConsumerKey; $ConsumerSecret; $AccessToken; $AccessTokenSecret; $Method; $URL; $Parameters; $Headers) ]
Set Variable [ $result ; Value: MBS("CURL.SetDebugWithData"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPostFields"; $curl; $Content; "UTF8") ]
# RUN now
Set Field [ CURL::Result ; MBS("CURL.Perform"; $curl) ]
# Check result
Set Field [ CURL::HTTP Response ; MBS("CURL.GetResponseCode"; $curl) ]
Set Field [ CURL::Customer Info ; MBS("CURL.GetResultAsText"; $curl; "UTF8") ]
Set Field [ CURL::debug ; MBS("CURL.GetDebugAsText"; $curl) ]
# Cleanup
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]

See also

Example Databases

Blog Entries

FileMaker Magazin

Release notes

  • Version 10.5
    • Added Realm Parameter for CURL.SetupOAuth function.
  • Version 8.3

Created 24th May 2018, last changed 21st September 2020


CURL.SetupAWS   -   CURL.Upkeep

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins