Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 7.2   7.3   7.4   7.5   8.0   8.1   8.2   8.3   8.4   8.5    Statistic  

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"; ConsumerKey; ConsumerSecret; AccessToken; AccessTokenSecret; HTTPVerb; URL { ; Parameters; Headers; Datas; Nonce; Timestamp; HMAC; Verifier } )   More

Parameters

Parameter Description Example value
ConsumerKey The oauth consumer key. "xvz1evFS4wEEPTGEFPHBog"
ConsumerSecret The oauth consumer secret. "kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw"
AccessToken The oauth access token. "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 Optional
List of parameters.
Can be empty.
Please pass list with newline as delimiter.
values should be URL encoded already.
"include_entities=true"
Headers Optional
List of additional header entries to include.
Can be empty.
We automatically set Authorization header.
"Accept: application/json¶Content-Type: application/json"
Datas Optional
Data value list for POST.
"status=Hello¶others=123"
Nonce Optional
The nonce value.
If empty, we generate it automatically for you.
"kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg"
Timestamp Optional
The timestamp to use for signature.
If empty, we query current timestamp (same as you calling Time.UnixTimeStamp)
1318622958
HMAC Optional
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"
Verifier Optional
The verifier. Usually an ID shown on a website after login to the service and authorization of an app.
"3456789"

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.Cleanup"; $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.Cleanup"; $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.Cleanup"; $curl) ]

See also

Example Databases

Created 24th May 2018, last changed 28th May 2018


CURL.SetupAWS   -   CURL.UseSystemCertificates

Feedback: Report problem or ask question.




Links
MBS Xojo Chart Plugins