Adding filter with curl for github api - github

How do i add the 2fa filter in curl for the github api?Here is an image of the documentation page, however it does not specify how to add the filter for 2fa.
Thanks so much!
I have tried using a "?":
curl
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer """
-H "X-GitHub-Api-Version: 2022-11-28"
https://api.github.com/orgs/"my_org_name"/members?2fa_disabled

According to the documentation, the query-parameter you need is called filter with the value 2fa_disabled. Therefore your curl command should look the following:
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/members?filter=2fa_disabled
Keep in mind that this options is only available for organization owners.
Documentation: https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#list-organization-members

Related

Github REST Api get workflow runs for a specific date range with cURL

I am trying to query Github's REST API to list workflow runs for specific date ranges.
Here's an example curl call:
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/[OWNER]/[REPO]/actions/runs?created:2023-01-01..2023-01-02"
From what I understand from the documentation, this is how I should be able to retrieve only results from Jan 1st and 2nd of 2023. But it does not work, my result is always the latest runs.
What am I doing wrong?
you should use the = symbol instead of :, like:
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_ACCESS_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/[OWNER]/[REPO]/actions/runs?created=2023-01-01..2023-01-02"

Configuration of reCAPTCHA for Keycloak via CLI

Is there a way to configure reCAPTCHA via the CLI for a Keycloak standalone installation? To be more precise, is it possible to carry out all the steps described here in the Keycloak docs with the help of kcadm.sh?
You can achieve that by using Keycloak Admin REST API.
The first step is to get an admin token, so that one can call the Rest API:
curl -d "client_id=admin-cli" \
-d "username=$ADMIN_NAME" \
-d "password=$ADMIN_PASSWORD" \
-d "grant_type=password" \
https://$KEYCLOAK_IP/auth/realms/master/protocol/openid-connect/token
You will get a json response with the admin token. Extract the access token from that response (lets called $ACCESS_TOKEN).
Now, we need to get the list of all executions linked to the registration flow:
curl -X GET https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/authentication/flows/registration/executions \
-H "Content-Type: application/json" \
-H "Authorization: bearer $ACCESS_TOKEN"
From that json response, extract the id of the "providerId=registration-recaptcha-action". Lets call that id, $ID_RECAPTCHA.
Next make the reCaptcha required at the registration:
CAPTCHA_DATA='{"id":"$ID_RECAPTCHA","requirement":"REQUIRED","providerId":"registration-recaptcha-action"}'
curl -X PUT https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/authentication/flows/registration/executions \
-H "Content-Type: application/json" \
-H "Authorization: bearer $ACCESS_TOKEN"\
-d "$JSON_DATA"
Finally, to configure your own captcha:
CONFIG_DATA='{"config":{"site.key":"<YOUR SITE KEY>","secret":"<YOUR SECRET>","useRecaptchaNet":"<True or False>"},"alias":"<The CAPTCHA ALIAS>"}'
curl -X POST https://$KEYCLOAK_IP/auth/admin/realms/$REALM_NAME/authentication/executions/$ID_RECAPTCHA/config \
-H "Content-Type: application/json" \
-H "Authorization: bearer $ACCESS_TOKEN"\
Next, the best thing is to automatize this process with, for instance, some bash scripts.

keycloak 4.8 Rest API

I'm trying to retrive the users list of a specific realm.
I've read this documentation uri schema user resource
So i've tried the following curl cmd:
curl \
-X GET \
-H "Authorization: bearer $KC_ACCESS_TOKEN" \
"http://localhost:8080/auth/$KC_REALM/users"
I got a 404 error.
The user exist in the realm and has the view-users role.
This is the docker-compose file that i'm using to test then env (docker-compose.yml)
Try:
curl \
-X GET \
-H "Authorization: bearer $KC_ACCESS_TOKEN" \
"http://localhost:8080/auth/admin/$KC_REALM/users"
Try this
curl \
-X GET \
-H "Authorization: bearer $KC_ACCESS_TOKEN" \
"http://localhost:8080/auth/admin/realms/{realm}/users"

How to add a label to an issue using GitHub API?

I'm trying to find a way to add a label to a GitHub issue using the API. After checking the API documentation I tried the following curl request:
curl -X POST -H "Authorization: token OOOOOOOOOOOOOOOO" -H \
"Accept: application/vnd.github.symmetra-preview+json" \
-d #label.json https://api.github.com/repos/CHSUNSONG/star-platform/issues/11
label.json contains:
["submitted"]
However, I got the following response:
{
"message": "Invalid request.\n\nFor 'links/1/schema', [\"submitted\"] is not an object.",
"documentation_url": "https://developer.github.com/v3/issues/#edit-an-issue"
}
Why isn't this working and how can I fix it?
You're POSTing to the wrong URL. Add /labels onto the end:
curl -X POST -H "Authorization: token OOOOOOOOOOOOOOOO" -H \
"Accept: application/vnd.github.symmetra-preview+json" \
-d #label.json \
https://api.github.com/repos/CHSUNSONG/star-platform/issues/11/labels

How to use Curl to invoke a Temboo API?

How can I use curl to invoke a Temboo API? I want to get a list of all Temboo APIs.
Below is the Curl example given on a Temboo Rest API webpage. I'm not sure how to change it for correct access.
curl -k --basic -u user#temboo.com:test1234 --header "Accept: application/xml" --header "Content-Type: application/xml" --header "x-temboo-domain: /myOrg/master" https://myOrg.temboolive.com:443/temboo-api/1.0/choreos
Changes:
Change user#temboo.com:test1234 to the email address and password on file at Temboo. e.g. toto#totomail.com:totopassword
Change all instances of myOrg to your Temboo account name. e.g. toto.
curl -k --basic -u toto#totomail.com:totopassword --header "Accept: application/xml" --header "Content-Type: application/xml" --header "x-temboo-domain: /toto/master" https://toto.temboolive.com:443/temboo-api/1.0/choreos