Can i get okta authentication worked in Desktop applications ? Where i just want to hit okta api to get access token and other details in response ?
As per my understanding it looks for some redirect_uri which i do not have in case of desktop application. Any recommendation ?
I tried it with my web application that works fine.
with following parameters
const openIdConnectUrl = 'https://xxxx.okta.com/oauth2/default';
const clientId = 'xxxxxxxxxxxxxxxxxxx';
const redirectUri = 'http://xxxx.com/yyy/zzz';
Reqeust
curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"username": "xxxx#example.com",
"password": "xxxxxx",
"relayState": "/myapp/some/deep/link/i/want/to/return/to",
"options": {
"multiOptionalFactorEnroll": false,
"warnBeforePasswordExpired": false
}
}' "https://${yourOktaDomain}/api/v1/authn"
provides response like
{"expiresAt":"2019-11-13T06:27:03.000Z","status":"SUCCESS","sessionToken":"20111PJIKs504fXVoLs-9zf4t8YoVzMCEvlUbcnjDnPhqSk7C-YPzCL","_embedded":{"user":{"id":"xxxxxxxxxxxxxxx","passwordChanged":"2019-11-13T03:20:33.000Z","profile":{"login":"xxxxxx#gmail.com","firstName":"xxxx","lastName":"xxxx","locale":"en","timeZone":"America/Los_Angeles"}}},"_links":{"cancel":{"href":"https://dev-924234.okta.com/api/v1/authn/cancel","hints":{"allow":["POST"]}}}}
Refer the below documentation if needed.
https://developer.okta.com/docs/reference/api/authn
Although it did not serve my purpose completely. But it can help you.
Related
How can I get the cookie from a request in playframework?
I have the following test endpoint
def home = Action.async { implicit request =>
println(request)
println(request.session)
println(request.flash)
request.session.get("session") match {
case Some(cookie) => Future(Ok(cookie))
case None =>
Future(BadRequest(Json.obj("message" -> "missing session cookie")))
}
}
When submitting the following request:
curl 'http://local.example.com:9000/home' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Cookie: session=eyJhbGciOiJSUzI1NiIsImtpZCI...' -H 'Upgrade-Insecure-Requests: 1' -H 'Cache-Control: max-age=0'
I unfortunately get the "missing session cookie" response. and the following printout on the console
GET /home
Session(Map())
Flash(Map())
I don't know what I'm doing wrong. Any help is much appreciated.
Edit: I set the cookie using the following method:
def tokenLogin = Action(parse.json).async { implicit request =>
val loginRequest = request.body.validate[LoginRequest]
loginRequest.fold(
errors =>
{
println(errors)
Future(BadRequest(Json.obj("message" -> JsError.toJson(errors))))
},
request => {
println("in success")
firebaseAdminService
.createSessionCookie(request.idToken)
.map(sessionCookie =>
Ok("success")
.withNewSession
.withCookies(Cookie(name = "session", value = sessionCookie))
)
}
)
}
By default, the session cookie in Play is called "PLAY_SESSION" (configuration play.http.session.cookieName).
So, you would need to use -H "Cookie: PLAY_SESSION=..." with curl.
But note, this won't work with arbitrary data since Play uses JWT and signs the information contained in the session cookie using its crypto secret.
The only thing expected to work is using a session cookie received in a Set-Cookie header from your Play service in another request to the same service (having the same secret).
update after your edit:
When using request.session, you are accessing the session cookie, which is called PLAY_SESSION and the information stored inside it.
But, you are setting a cookie of your own. This is something else.
You can access "normal" cookies with
request.cookies.get("session")
Oh, and in case you really wanted to make use of the session cookie, you can set it like this:
Ok("success").withSession("session" -> sessionCookie)
when calling
curl -XPUT -H "content-type: application/json" -d
'{"path":"/models/testALS.zip"}' http://localhost:65327/model
get error.
I use spark-mllib trained an als model and save the model as testALS.zip
when calling this
curl -XPUT -H "content-type: application/json" -d
'{"path":"/models/testALS.zip"}' http://localhost:65327/model
has error;
the error message is pasted below.
[ERROR] [05/10/2019 04:10:57.815] [MleapServing-akka.actor.default-dispatcher-3] [MleapResource] error with request java.util.NoSuchElementException: key not found: als at scala.collection.MapLike$class.default(MapLike.scala:228) at scala.collection.AbstractMap.default(Map.scala:59) at scala.collection.MapLike$class.apply(MapLike.scala:141) at scala.collection.AbstractMap.apply(Map.scala:59) at ml.combust.bundle.BundleRegistry.model(BundleRegistry.scala:93) at ml.combust.bundle.serializer.ModelSerializer$$anonfun$readWithModel$2.apply(ModelSerializer.scala:105)
I believe the endpoint you are using is for updating an existing, loaded model. I'm not sure which version of MLeap you are using, so here is how I would load a model:
I recommend using at least version 0.13.1.
I recommend using the spring boot server, which is on port 8080
Then, you need to load a model using POST:
curl -X POST http://localhost:8080/models \
-H 'Content-Type: application/json' \
-d '{"modelName":"airbnb", "uri":"file:/models/airbnb.model.lr.zip", "config": {"memoryTimeout": 10000, "diskTimeout": 10000}, "force": false}'
I am performing the following POST in a Tower server:
http://<my-tower-url>/api/v2/job_templates/10/launch/
Headers:
Content-Type:application/json
Authorization:sometokenhere
And getting back the error:
{"detail":"Authentication credentials were not provided."}
Have also tried the following:
Headers:
Content-Type:application/json
Authorization:Token sometokenhere
as suggested here.
Same happens when passing raw username/password in the POST body as follows (and skipping the Authorization header):
{
"username": "myusername",
"password": "mypass",
"inventory": "inventoryname",
"verbosity": 0,
"extra_vars": {
"var1": "somevar1",
"var2": "somevar2",
"var3": "somevar3",
"var4": "somevar4",
"var5": "somevar5"
}
}
Any idea why this is not working?
Authorization: Bearer <oauth2-token-value>
See here, Section "3. OAuth 2 Token Authentication", part "Curl Example".
I ended up using basic auth as follows:
1.create the user which you want to run your ci jobs with
2.perform the following post at the respective CI job:
curl -o /dev/null -s -w \"%{http_code}\n\" -X POST http://<my-tower-url>/api/v2/job_templates/10/launch/ \
-H \"authorization: Basic $MY_AUTH_TOKEN\" \
-H \"content-type: application/json\" \
-d \"#awx_data.json
Where
awx_data.json is a file holding the actual POST body
MY_AUTH_TOKEN is the tyical base64 encoded username+password of the above user
You can also assign the above result and check it against 201 which is what AWX returns upon successful job creation.
Polling the AWX server to check if the job was successfully finished is another story of course.
I wrote this code with bash for send Messages with telegram bot, now i need send the Message with a custom URL.
This is my actual code:
sendTelegram() {
curl -s \
-X POST \
https://api.telegram.org/bot$apiToken/sendMessage \
-d text="$download" \
-d chat_id=$userChatId
}
How to I can send the Message $download in a URL Button, for example:
You need to use an inline_keyboard from reply_markup and send a POST request with a JSON content type header:
curl -d '{"chat_id":7455490, "text":"pruebax", "reply_markup": {"inline_keyboard": [[{"text":"LaResistencia.co", "url": "http://laresistencia.co"}]]} }' -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$apiToken/sendMessage
Check the Telegram bot API inline_keyboard section for more info about the parameters:
https://core.telegram.org/bots/api#inlinekeyboardbutton
Please use reply_markup like this payload.
I'm writing a cloud code function in parse and I'm trying to figure out how to handle parameters in the GET url.
So I have a simple function like this:
Parse.Cloud.define("someFunction", function(request, response) {
// how can I use GET parameters here??
});
How to I rename the "someFunction" to handle GET parameters so I can use them in my cloud code function logic?
so for example I want to be able to pass in a name string: "myName" in the GET
https://api.parse.com/1/functions/someFunction?name=myName
Any simple example? I searched for a while I couldn't find one.
Thank you
EDIT:
So I modified my function to look like this:
Parse.Cloud.define("someFunction", function(request, response) {
// how can I use GET parameters here??
var name = request.params.name
response.success("the name = " + name)
});
then I call it like this:
https://api.parse.com/1/functions/someFunction?name=someName
what I get back is this:
{"result":"the name = **undefined**"}
Cloud Functions are called with a POST request, not a GET request. Here is a simple example for cURL I took from the documentation [1].
curl -X POST \
-H "X-Parse-Application-Id: YOUR_APP_ID" \
-H "X-Parse-REST-API-Key: YOUR_REST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"John Doe"}' \
https://api.parse.com/1/functions/someFunction
[1] https://www.parse.com/docs/cloud_code_guide#functions
try calling the Cloud from JS layer...
Parse.initialize(appId, jsId);
p = Parse.Cloud.run('someFunc', {"name":refToName}).then(function(result) {