Keystone GET user email - rest

Hello I have been trying to get my contact information using the REST API that Keystone has without success
I'm using an unscoped token and i'm getting a 401 Unauthorized even with the admin user, and i'm authenticating against the port 5000 and querying through the 35357 the user's info so at the end I would like to have the email address, this is the curl command that I use:
curl -i -H 'Content-Type: application/json' -H 'X-Auth-Token: PKIZ_eJxVlEmPqzgQgO..' http://192.168.44.132:35357/v2.0/users/my_user
This is a fresh devstack installation. Thank you

I finally got this thing working It was the token I forgot to add to the 'tenantName': 'admin'
Old
{ 'auth'=> { 'passwordCredentials' => { 'username' => username, 'password' => password } } }
New
{ 'auth'=> { 'tenantName' => 'admin', 'passwordCredentials' => { 'username' => username, 'password' => password } } }

Related

Perl-Rest::Client and credentials

Got an application where credentials don't work on curl with the -u option, I've to pass them with the -d option like that :
curl -v -k -X 'POST' --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ "auth_info":{ "username":"myuser", "password":"mypwd" } }' 'https://.../rest/v1.0/auth'
With the rest::client in Perl, I can send credentials using the session headers, but it works only when application accepts the -u parameter of curl.
So I'm trying to have the solution to identify myself against this application with the rest::client
Tried with :
%CONTENT_JSON = (
'auth_info' => (
'username' => 'myuser',
'password' => 'mypwd')
);
$CONTENT_JSON = encode_json(\%CONTENT_JSON);
But I've the following error message on return of the query :
$VAR1 = {
'service_status' => {
'details' => 'JSON request struct field is empty or invalid.',
'code' => 5437
}
};
Any help appreciated...

Auth laravel parse

I have problem with login laravel parse. I use auth for connection and I use this library for to do parsehttps://github.com/sirthxalot/laravel-parse and the doc for tutorial https://laravel-parse.readthedocs.io/en/latest/fundamentals/object-model.html
if (Auth::attempt(['email' => $email, 'password' => $password])) {
echo "OK";
}else{
echo "Bad post";
}
After the post data, my result is "bad post"
please help me

Error pulling companies user is admin of in LinkedIn

I'm currently trying to pull the list of company pages a user is the admin of with the LinkedIn API and am getting the following response:
Array
(
[response] => {
"errorCode": 0,
"message": "Member does not have permission to get companies as admin.",
"requestId": "R1LHP32UKD",
"status": 403,
"timestamp": 1482357250945
}
[http_code] => 403
)
The call works perfectly when authenticated as the same user in the LinkedIn API Console.
Has anyone else come across this?
I figured out the problem.
Even though I had made sure the app had the rw_company_admin permission checked off, I wasn't passing that in the scope when requesting oath2 authorization.
My fixed code below:
The call:
return $linkedin->getAuthorizationUrl("r_basicprofile w_share rw_company_admin", $thisurl);
The function:
public function getAuthorizationUrl($scope, $callback)
{
$params = array('response_type' => 'code',
'client_id' => $this->api_key,
'scope' => $scope,
'state' => uniqid('', true), // unique long string
'redirect_uri' => $callback,
);
// Authentication request
$url = 'https://www.linkedin.com/uas/oauth2/authorization?' . http_build_query($params);
// Needed to identify request when it returns to us
$_SESSION['Linkedin_state'] = $params['state'];
$_SESSION['Linkedin_callback'] = $callback;
// this is where to send the user
return $url;
}
First you have to get user token of linkedin user
Use Socialite or REST API package for oauth.
Once you having user token it is pretty simple to fetch Company list under admin user
$token = 'uflefjefheilhfbwrfliehbwfeklfw'; // user token
$api_url = "https://api.linkedin.com/v1/companies?oauth2_access_token=".$token."&format=json&is-company-admin=true";
$pages = json_decode(file_get_contents($api_url));
You have get $pages json array of list of company profile.

Authenticate AWS API gateway with AWS_IAM and API key from REST client Postman

I am trying to access authenticated POST API gateway with postman rest client, but I am getting status 403 with forbidden message.
{
"message": "Forbidden"
}
I am using AWS Signature Authentication with AccessKey, SecretKey, AWS Region and Service Name. I don't understand why its not allowing my rest call, is it something to do with my AccessKey and SecretKey pair lacking authorisation?? (My user is Admin thought)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://xxxxxxxxxx.execute-api.us-west-2.amazonaws.com/dev/score",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "input1=1&input2=2",
CURLOPT_HTTPHEADER => array(
"authorization: AAAA-AAAA-XXX123 Credential=XXXXXXXXXX/20160414/us-west-2/execute-api/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=sdddddssdddddddddddddddddsdsdsdsdsdsdsdsdsdsd",
"cache-control: no-cache",
"content-type: application/javascript",
"host: xxxxxxxxxx.execute-api.us-west-2.amazonaws.com",
"postman-token: abf462fe-24ae-244d-ba8d-d3e953f0e712",
"x-amz-date: 20160414T084331Z"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
If you are using an API Key, make sure you set the "x-api-key" header.
I also had the same problem until I created a Usage Plan and linked the plan to the API stage and the API key.
If you set 'API Key Required' option to true, please check below.
Deploy your API to update changes.
you have to pass 'x-api-key' HTTP Header Parameter to API Gateway.
The API Key had to be created.
In addition, you need to check a Usage Plan for the API Key on API Gateway Console.
This can have multiple reasons, would you mind sharing a sample setup where it fails?
Please check the following:
Did you deploy your API?
Does the user have the proper permissions? You can use the managed IAM policy "AmazonAPIGatewayInvokeFullAccess" or create your own. Please refer to our documentation for more details.
Best,
Jurgen, API Gateway
It often happens when API is not deployed to API Gateway or you are accessing the wrong path /your-rout instead of /api-name/your-route.

Parse REST API set ACL to an object

I'm trying to set the ACL permissions for an object created through the Parse REST API. I want it to have only public read access. Only the server can create or modify the objects in the class. I read the parse REST documentation on how to set ACL permissions.
When I run the following:
$InputData = array('votes' => 1, 'ACL' => array('*' => array('read' => true, 'write' => false)), 'user' => array('__type' => 'Pointer', 'className' => '_User', 'objectId' => $objectId));
$rest = curl_init();
curl_setopt($rest,CURLOPT_URL,$url);
curl_setopt($rest,CURLOPT_PORT,443);
curl_setopt($rest,CURLOPT_POST,1);
curl_setopt($rest,CURLOPT_POSTFIELDS, json_encode($InputData));
curl_setopt($rest,CURLOPT_HTTPHEADER,
array("X-Parse-Application-Id: " . $appId,
"X-Parse-Master-Key: " . $restKey,
"Content-Type: application/json"));
I get:
{"code":123,"error":"Invalid acl {\"*\":{\"read\":false,\"write\":false}}"} 1
What is wrong with my code, specifically the ACL part? Help!
Hope it helps.
curl -X POST \
-H "Content-Type: application/json" \
-H "X-Parse-Application-Id: xxxxxxxxxxxxxxx" \
-H "X-Parse-REST-API-Key: xxxxxxxxxxxxx" \
-H "X-Parse-Session-Token: xxxxxxxxxxxxxx" \
-d "{\"name\":\"MyName\", \"ACL\": {\"ErKLiQfj8Q\" : { \"read\": true, \"write\": true }, \"*\" : {}}}" \
https://api.parse.com/1/classes/Tasks
JSON obj
{
"name":"MyName",
"ACL":
{
"ErKLiQfj8Q" : { "read": true, "write": true },
"*" : {}
}
}