Go Back
Multi-step REST Auth Flow Example (OAuth, etc)
Publisher
: Lingk
Run In Lingk
Description
This recipe makes a request for an authentication token, inserts the value into Execution Content and uses the token for subsequent request. To run this recipe, add the headers for the first step of your
Browse the knowledge base
Twitter
E-Mail
# _____ _ _____ __ # | __ \ (_) |_ _| / _| # | |__) |___ ___ _ _ __ ___ | | _ __ | |_ ___ # | _ // _ \/ __| | '_ \ / _ \ | | | '_ \| _/ _ \ # | | \ \ __/ (__| | |_) | __/ _| |_| | | | || (_) | # |_| \_\___|\___|_| .__/ \___| |_____|_| |_|_| \___/ # | | # |_| # Project Name - MULTI-STEP REST AUTH FLOW EXAMPLE (OAUTH, ETC) # Recipe URL - https://app.lingk.io/a/10932/tf/17819 # Description - # This recipe makes a request for an authentication token, inserts the value into Execution Content and uses the token for subsequent request. # To run this recipe, add the headers for the first step of your # Industry - Higher Ed # Business Process - Graduate Reporting # Systems - Generic API # Connectors - HTTP # Data Flows - Single Direction # Connection Type - API # Add Recipe notes / Change log information here! # _____ _ # / ____| | | # | | ___ _ __ _ __ ___ ___| |_ ___ _ __ ___ # | | / _ \| '_ \| '_ \ / _ \/ __| __/ _ \| '__/ __| # | |___| (_) | | | | | | | __/ (__| || (_) | | \__ \ # \_____\___/|_| |_|_| |_|\___|\___|\__\___/|_| |___/ # # CONNECTORS specify what data will be pulled into the in-memory database during processing connectors: # Configure HTTP credentials in your Environment before running this recipe # HTTP Setup - https://help.lingk.io/en/articles/304-http-connector-setup-guide ###### Start - HTTP Reader connectors ###### # Get an auth token for an API using a Oauth Password grant - name: tokenInput type: httpReader properties: url: https://integrate.myapi.com/auth httpMethod: POST acceptInvalidCerts: true headersJson: | { "Content-Type": "application/x-www-form-urlencoded" } # this value can be read in dynamically added from a properties file body: grant_type=password&client_id=[myclientId]&client_secret=[mysecret]&username=[myusername]&password=[mypassword] #schemaRef: schemaName # optional from " # Get persons # Note: this connector does not handle paging - name: getPersons type: httpReader delayedRead: true # delays the exection of this connector until a REFRESH statement properties: url: https://integrate.myapi.com/api/persons headersJson: > { "Authorization":"Bearer {{executionContext.authToken.access_token}}", "Content-Type": "application/json" } httpMethod: GET ###### End - HTTP Reader connectors ###### # _____ _ _ _ # / ____| | | | | | # | (___ | |_ __ _| |_ ___ _ __ ___ ___ _ __ | |_ ___ # \___ \| __/ _` | __/ _ \ '_ ` _ \ / _ \ '_ \| __/ __| # ____) | || (_| | || __/ | | | | | __/ | | | |_\__ \ # |_____/ \__\__,_|\__\___|_| |_| |_|\___|_| |_|\__|___/ # STATEMENTS specify how the data should be processed while in memory statements: #******************************************************************** D I S C L A I M E R *********************************************************************************************** # * # Note that in an effort to keep recipes optimized for DPH (Data Processing Hours), print statements should be commented out after development has concluded for a recipe. * # For more information on DPH optimization, please visit the following help article - https://help.lingk.io/en/articles/212-minimizing-data-processing-hours-on-the-lingk-platform * # * #******************************************************************** D I S C L A I M E R *********************************************************************************************** # The auth token is retrieved as the first read # Now we want to get the auth token and put it into exectionContext - statement: (authToken) => select access_token from tokenInput #- statement: print authToken - statement: insert authToken into executionContext # To have the authToken applied to each request use a REFRESH statement type with either "delayedRead" or "parameterizedBy" properties - statement: refresh getPersons #- statement: print getPersons # Add more statements to convert, join, aggregrate, transform, and integrate your data
Dynamically Building JSON and XML Arrays Using Template Expressions
Snowflake - Read Tables and Write CSV Data