Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Twitter API - Signature - SHA1

Martin_Bosak
7 - Meteor

Hi,

 

I'm trying to develop algorithm for twitter API - for creating signature: https://dev.twitter.com/oauth/overview/creating-signatures

Do we have something for twitter like this, or is there any macro to calculate HMAC-SHA1 other than calling external program?

 

Thank you

Martin

16 REPLIES 16
jdunkerley79
ACE Emeritus
ACE Emeritus

I have been working on some custom .Net tools, one of them includes exposing the various hash algorithms.

 

See https://github.com/jdunkerley/AlteryxAddIns/blob/master/AlteryxAddIns/HashingTool.cs

 

 

Hoping to get this released next week, you are welcome to use it.

 

 

KaneG
Alteryx Alumni (Retired)

Hi Martin,

 

I'm guessing you may want to do a little more than the in-built twitter tool in Alteryx, hence why you are doing it manually, but you can open that tool up and see how the Authentication is done... just be careful not to save over the top of it. There is also an Oauth Macro on the Engine Works Blog which may give you some ideas.

 

Kane

Martin_Bosak
7 - Meteor

Yes good point Kane,

 

I've done this. But in-build twitter tool in Alteryx uses only an application-level authorization, not the one with tokens for access home timeline etc. If I'm right.

OAuth works well. But it seems like twitter API need to have every request signed by relatively easy but long algorithm with SHA1.

Now I'm using 3rd party tool for accessing twitter, maybe it is the easiest way.

 

Martin

michael_treadwell
ACE Emeritus
ACE Emeritus

I've encountered this same issue and resolved it using the Alteryx R Tool. The package 'digest' contains function hmac() to calculate HMAC-SHA1.

Coxta45
11 - Bolide
Care to share your R code? I've been trying to do this in the R-tool and can't quite get it right.
Martin_Bosak
7 - Meteor

Im using following - but im not sure if it is right.. (Im not R person), please correct me if not

 

package_name <- "digest"
# grab the alteryx repo
altx.repo <- getOption("repos")
altx.repo["CRAN"] <- "http://cran.rstudio.com" # set your primary repo if you haven't already
options(repos = altx.repo)
#check to see if the package we want is already installed
# if it is, we will just load it, otherwise we will install it
if(package_name %in% rownames(installed.packages())==FALSE){
install.packages(package_name)
}
require(package_name, character.only=TRUE)

data <- read.Alteryx("#1", mode="data.frame")

f <- function(x, output) {
hash <- x[1]
base <- x[2]
output <- hmac(hash, base, "sha1")

}
current <- apply(data, 1, f, output = 'outputfile')
write.Alteryx(current, 1)

 

Coxta45
11 - Bolide

Thanks, Martin.

 

I'm definitely not an R person either, but it seems to be the only way to sign a WebService request with SHA1 hashing.  I'll see if I'm able to make use of this.  

 

Regards,

Taylor

Coxta45
11 - Bolide

This is very similar to what I was trying to do.  I guess my problem is that I also don't understand the HMAC usage.  For instance,  I'm trying to call Adobe Marketing Cloud API endpoints.  Their documentation requires that I send (in headers) a Nonce (via the UuidCreate() function), a Created timestamp, and a Digest.  The digest is the SHA1 hash of the Nonce + Created + SecretKey (concatenated).  So where I am a bit lost is in the HMAC function in R, what is the 'Hash' and what is the 'Base' that I feed the function?

 

Any insights?

jdunkerley79
ACE Emeritus
ACE Emeritus

You are welcome to try my addins. It will take a string and create SHA-1 for it.

 

Need installed but can download newest version from https://github.com/jdunkerley/AlteryxAddIns/releases/tag/v0.3

 

Demo workflow attached.

Labels