Sophos Intellix Authenticate API Error trying to Authenticate - sophoslabs-intelix

I am trying to authenticate to the sophos intellix authenticate api:
curl --location --request POST 'https://api.labs.sophos.com​/oauth2​/token'
--header 'Content-Type: application/json;charset=UTF-8'
--header 'Authorization: Basic {encoded key:secret}'
--data-raw 'grant_type=client_credentials
I am receiving this response:
400 ERROR
The request could not be satisfied.
Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: cbA_F5avox5aIXvXdc91LFbn0PylJY4LfKqB_bYL7dfMsgCFElTArA==
What am I missing in the cURL request?

Oh gosh... had the wrong content type header value
--header 'Content-Type: application/x-www-form-urlencoded'
The full curl request:
curl --location -X POST 'https://api.labs.sophos.com​/oauth2​/token' --header 'Content-Type: application/x-www-form-urlencoded' --header 'Authorization: Basic {encoded key:secret}' --data-raw 'grant_type=client_credentials' -i

Related

Auth0 Request and use a Management API token from a Flutter App

We need to allow our Flutter application to save a property in the user_metadata when the application starts.
As I understand this is a task to be done with the Management API and in order for the Flutter application to be able to write in the user_metadata the client has to request a Management API access token.
I found no information on how to request this token, the closest thing is this page in the documentation that has no example and no explanation on how to retrieve this token:
https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications
Can anyone provide an example on how to request this token from a Flutter app?
Even a generic CURL request would be helpful to understand what endpoint to call with which parameters.
Error received when trying to access the Management API to update the user_metadata:
body{
"statusCode":400,
"error":"Bad Request",
"message":"Bad HTTP authentication header format",
"errorCode":"Bearer"
}
2 steps are needed:
Get the authentication token for management API:
sample curl:
curl --location --request POST "https://YOUR_AUTH0_DOMAIN/oauth/token" \
--header "content-type: application/json" \
--data-raw "{
\"grant_type\": \"client_credentials\",
\"audience\": \"https://YOUR_AUTH0_DOMAIN/api/v2/\",
\"client_id\": \"YOUR_AUTH0_APPLICATION_CLIENT_ID\",
\"client_secret\": \"YOUR_AUTH0_APPLICATION_CLIENT_SECRET\"
}"
call the management api to update app_metadata
sample curl:
curl --request PATCH \
--url 'https://YOUR_AUTH0_DOMAIN/api/v2/users/USER_ID' \
--header 'authorization: Bearer TOKEN_FROM_STEP_1' \
--header 'content-type: application/json' \
--data '{"email": "whatever#example.com", "user_metadata": {"hobby": "surfing"}, "app_metadata": {"plan": "full"}}'
Edit: Patch request with userID

GitHub API Create Repo returning 403?

I'm making a GitHub app, and I'm trying to create a repo according to this documentation
https://docs.github.com/en/free-pro-team#latest/rest/reference/repos#create-a-repository-for-the-authenticated-user
When I make a GET request to that URL, it works and I get the user's repos, but making a post request like this:
curl --request POST \
--url https://api.github.com/user/repos \
--header 'authorization: token [user_access_token]' \
--data '{"name": "test"}'
Returns this
{
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user"
}
My app has access to this permission:

Want Keycloak Rest API Request format for sending otp in case of multiple credentials are present

I have two devices set for a user in case of Otp generation for Multi Factor Authentication.For Browser, It is asking me to choose the device.
I want to achieve same from Rest api.
Kindly suggest.
Currently i am using below request but 401 unauthorized error is being received.
curl --location --request POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' --header 'Content-Type: application/x-www-form-urlencoded' --header 'Content-Type: application/x-www-form-urlencoded' --header --data-urlencode 'client_id=admin-cli' --data-urlencode 'username=shagun' --data-urlencode 'password=Abc#1234' --data-urlencode 'grant_type=password' --data-urlencode 'totp=823708'
You can use any of the device, the OTP will stay the same. After you have the OTP you can make REST calls and fetch the token. Below is the POSTMAN screen shot :-

IBM App ID API Calls: How to add attributes to customise a user with REST API?

I have created a NodeJS application on IBM Cloud and connected it with the App ID Service. In that Service, I have added a user and setup the redirect URI. I can successfully log in with the user account by using Cloud Directory as the Identity Provider and I can see the /userinfo as well as the ID and Access Token (Bearer). I would like to change and add attributes of that user, but my PUT or POST requests do not work. However, my GET request is working:
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer token' 'https://appid-oauth.eu-gb.bluemix.net/oauth/v3/91c8d285-580a-47ae-8928-e47e17127a35/userinfo'
I have tried following PUT and POST requests:
curl -X POST --header 'Content-Type: text/plain' --header 'Accept: application/json' --header 'Authorization: Bearer token' -d 'value' 'https://appid-profiles.ng.bluemix.net/userinfo'
and this:
curl -X POST --header 'Content-Type: text/plain' --header 'Accept: application/json' --header 'Authorization: Bearer token' -d 'attributeValue' 'https://appid-profiles.ng.bluemix.net/api/v1/attributes/attributeName'
This is the response:
Error 404: SRVE0295E: Error reported: 404
Using Postman, the response is:
Cannot POST or PUT /oauth/v3/91c8d285-58.../api/v1/attributes
How do I add attributes to a user using REST API?
See the API at: https://appid-profiles.ng.bluemix.net/swagger-ui/index.html#!/Attributes/setAttribute
You cannot use POST to set an attribute, you should use PUT

Uber Rush API Sandbox

Trying to test Uber Rush API (from localhost and from linux server).
Calling Token works - I get the token
trying to implement sanbox example:
curl -X "PUT /v1/sandbox/deliveries/{delivery_id}" \
-H "Authorization: Bearer <OAUTH TOKEN>" \
-d "{\"status\":\"en_route_to_pickup\"}"
with url https://sandbox-api.uber.com/
and I tried the same request with file_get_contents (in PHP)
So, I always get error "405 Method Not Allowed"
{"message":"Method not supported for this endpoint.","code":"method_not_allowed"}
What I need to do to get access to method from this sandbox example https://developer.uber.com/docs/rush/sandbox?
Corrent syntax
curl -X "PUT" -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" -d "{\"status\":\"en_route_to_pickup\"}" https://sandbox-api.uber.com/v1/sandbox/deliveries/DELIVERY_ID
EDIT: Updated to reflect both issues in your question...
You have a mismatch in your requests and an incorrect syntax for curl.
First off your CURL request is incorrectly specified. It should be:
curl -X "PUT" -H "Authorization: Bearer <OAUTH TOKEN>" -d "{\"status\":\"en_route_to_pickup\"}" https://sandbox-api.uber.com/v1/sandbox/deliveries/{delivery_id}
In addition, your curl command is trying to issue a PUT request to the uber sandbox PUT API. However, your PHP code is not setting the context correctly and so is probably issuing a GET request. I suspect that the server is therefore rejecting the request as a GET as not allowed to do this sort of operation.
To fix it, see Bad request using file_get_contents for PUT request in PHP. This should give you an example of how to pass in the necessary context to issue a PUT request using file_get_contents().