Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass user authentication in notebook #3

Closed
ashitabh opened this issue Nov 23, 2018 · 4 comments
Closed

How to pass user authentication in notebook #3

ashitabh opened this issue Nov 23, 2018 · 4 comments

Comments

@ashitabh
Copy link

ashitabh commented Nov 23, 2018

How do I pass header -> Authorization : Bearer xxxyyyzzz" in notebook

@mikeyoungyoung
Copy link

mikeyoungyoung commented Jan 8, 2019

@ashitabh have you solved this yet? I'm running into the same issue. I can only successfully authenticate when the keys are held as query params. Header params are not working for me

@sourav-mazumder any help with that?

@ashitabh
Copy link
Author

ashitabh commented Jan 8, 2019

Hi Mike, I did some changes in RestConnectorUtil.scala.
Line no: 53 for Get method

 var httpc = (method: @switch) match {
      //case "GET" => Http(addQryParmToUri(uri, data)).header("contenty-type",
       //              "application/x-www-form-urlencoded")
	   case "GET" => Http(addQryParmToUri(uri, data)).header("Authorization",authToken)
      case "PUT" => Http(uri).put(data).header("content-type", contentType)
      case "DELETE" => Http(uri).method("DELETE")
      case "POST" => Http(uri).postData(data).header("content-type", contentType)
    }

and then from notebook/ spark code I used the following

val sodauri = "https://somesrestapi.com/v4/entity/user"
val parmg = Map("url" -> sodauri, "input" -> "sodainputtbl", "method" -> "GET","authType"->"Basic","authToken"->"Auth-Token xxxxx","readTimeout" -> "200000", "connectionTimeout" -> "200000", "partitions" -> "10")
val sodasDf = spark.read.format("org.apache.dsext.spark.datasource.rest.RestDataSource").options(parmg).load()

@mikeyoungyoung
Copy link

@ashitabh okay cool, I was expecting something similar. Unfortunately the headers in most of the apis I use are very different... so will have to build a header builder util or something

@amandal1810
Copy link

the authorization header key-value can be added for the POST method as well
case "POST" => Http(uri).postData(data).header("Content-Type", contentType).header("Authorization",authToken)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants