I am attempting to create a user on my Chef Server through the Chef Server API. I am currently using a PHP wrapper for the API interface which can be found here.
I understand that in order to create a user using the API, you must provide the pivotal.pem file as well as the pivotal username.
Here is a snippet of my PHP code that I am using:
// ENVIRONMENT VARIABLES
// The URL for the Chef Server
$server = "mycompany.com";
// The name used when authenticating
$client = 'pivotal';
// The location of the file which contains the client key
$key = "../../../pivotal.pem";
// The version of the Chef Server API that is being used
$version = "12.0.2";
// Create a Chef object
$chef = new Chef($server, $client, $key, $version);
// API Request
$createUserRequest = array("name"=>$displayName, "display_name"=>$displayName, "email"=>$emailAddress, "password"=>$password);
$createUserRequest = json_encode($createUserRequest);
$chef->post('/users/', $createUserRequest);
Here is the reponse that I receive from the server:
Fatal error: Uncaught exception 'Exception' with message 'Invalid signature for user or client 'pivotal'' in C:\Workspace\SA_SSAF\app\plugin\CHEF\Chef PHP\src\Jenssegers\Chef\Chef.php:187
Stack trace:
#0 C:\..\..\app\plugin\CHEF\Chef PHP\src\Jenssegers\Chef\Chef.php(70): Jenssegers\Chef\Chef->api('/users/', 'POST', '{"name":"entra"...')
#1 C:\..\..\app\plugin\CHEF\controller\chefEnrollUser.php(55): Jenssegers\Chef\Chef->post('/users/', '{"name":"entra"...')
#2 {main}
thrown in C:\..\..\app\plugin\CHEF\Chef PHP\src\Jenssegers\Chef\Chef.php on line 187
If I try and perform a GET request using the same configuration, I receive a successful response.
Any clues as to why something like this may be happening?
Thanks
Related
I am using the following example backend-auth Google
<?php
require_once 'Google/vendor/autoload.php';
$CLIENT_ID = "xxxxxxxxxx";
// Get $id_token via HTTPS POST.
$client = new Google_Client(['client_id' => $CLIENT_ID]); // Specify the CLIENT_ID of the app that accesses the backend
$payload = $client->verifyIdToken($id_token);
if ($payload) {
$userid = $payload['sub'];
// If request specified a G Suite domain:
//$domain = $payload['hd'];
} else {
// Invalid ID token
}
?>
I have already created the credentials, API, and OAUTH2
API_KEY: AIzaAsDfGuYn6nk9761kvnwMxns-PPeO1Ka1YsA
CLIENT_ID: 15123456862-94jrd0d2lis29lbl6dekpk0fp4otgm8r.apps.googleusercontent.com
CLIENT_SECRET: qertf3l3UfgdhjiWEREZI8xN
But it generates the following error:
Notice: Undefined variable: id_token in C:\Adsense\index.php on line 10
Fatal error: Uncaught LogicException: id_token must be passed in or set as part of setAccessToken in C:\Adsense\Google\vendor\google\apiclient\src\Client.php:784 Stack trace: #0 C:\Adsense\index.php(10): Google\Client->verifyIdToken(NULL) #1 {main} thrown in C:\Adsense\Google\vendor\google\apiclient\src\Client.php on line 784
I have searched this forum in the google documentation and in the google console panel but I cannot find a fixed token or how to create it, I cannot find references
https://oauth2.googleapis.com/tokeninfo?id_token=XXXXX
It's a bit of an old post, but for anyone like me and the OP struggling with this, it's actually quite a simple solution.
The example code has a commented out line that reads
// Get $id_token via HTTPS POST.
You actually have to write this code. Using the worked examples from Google, the JavaScript function passes the authentication token as idtoken.
$id_token = $_POST['idtoken'];
Will do the trick. You'll probably want to perform some basic error checking, for example,
if (isset($_POST['idtoken'])){
$id_token = $_POST['idtoken'];
$payload = $client->verifyIdToken($id_token);
...
I'm trying to manually connect with my App on Quickbooks online authorising with Oauthv2.0 using the consolibyte authorisation button located at
https://www.example.com/quickbooks-php/partner_platform/example_app_ipp_v3/quickbooks-php/partner_platform/example_app_ipp_v3/index.php
I'm getting the following fatal error message in oauth.php when trying to authorise Quickbooks online in Sandbox mode using the consolibyte quickbooks php framework on my secure domain.
I have made sure I'm using the correct development id / secret and that Oauth 2.0 is turned on and saved in the Intuit developer Settings for my app but can't see what is causing this error.
Error message:
Fatal error: Uncaught Error: Call to undefined function mcrypt_module_open() in ---quickbooks-php/QuickBooks/Encryption/Aes.php:34
Stack trace: #0 ---quickbooks-php/QuickBooks/Driver.php
(1433): QuickBooks_Encryption_AES::encrypt('XXXXXXXX', 'a:2:{i:0;s:778:...')
\#1 ---quickbooks-php/QuickBooks/IPP/IntuitAnywhere.php
(489): QuickBooks_Driver->oauthAccessWriteV2('XXXXXXXX', 'XXXXXXXXXXXXX...', 'XXXXXXXXXXXX...', XXXXXXXXXXXX...', '2019-09-12 16:1...', '2019-12-22 15:1...', 'XXXXXXXXXXX')
\#2 ---quickbooks-php/docs/partner_platform/example_app_ipp_v3/oauth.php
(25): QuickBooks_IPP_IntuitAnywhere->handle(XXXXX)
\#3 {main} thrown in ---quickbooks-php/QuickBooks/Encryption/Aes.php on line 34
Top part of Config file:
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Require the library code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';
//development id and secret
$oauth_client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$oauth_client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$sandbox = true; // When you're using development tokens
$quickbooks_oauth_url = 'https://www.example.com/quickbooks-php/docs/partner_platform/example_app_ipp_v3/oauth.php';
$quickbooks_success_url = 'https://www.example.com/quickbooks-php/partner_platform/example_app_ipp_v3/success.php';
$quickbooks_menu_url = 'https://www.example.com/quickbooks-php/partner_platform/example_app_ipp_v3/example_app_ipp_v3/menu.php';
$dsn = 'mysqli://db_username:XXXXXXXXXX#ipaddress/db_name';
// You should set this to an encryption key specific to your app
$encryption_key = 'xxxxxxxx'; //default value used here
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
I have this code:
require_once dirname(__FILE__)."/Chat-API-master/src/Registration.php";
$username = '972********'; // Your number with country code, ie: 34123456789
$nickname = 'A****'; // Your nickname, it will appear in push notifications
$debug = true; // Shows debug log, this is set to false if not specified
$log = true; // Enables log file, this is set to false if not specified
$dst = '+9725******';
$code = '17****';
$password="";
//$w = new WhatsProt($username, $nickname, $debug, $log);
$r = new Registration($username, $debug);
//$r->codeRequest('sms'); // could be 'voice' too
//$result=$r->codeRequest('sms'); // could be 'voice' too
$r->codeRegister($code);
I took the library from this link:
https://github.com/WHAnonymous/Chat-API/wiki/WhatsAPI-Documentation
I applied the code execution as it is described. I receieved the SMS, then I used the register function, and I got this error.
Fatal error: Uncaught exception 'Exception' with message 'An error occurred registering the registration code from WhatsApp. Reason: missing' in C:\xampp\htdocs\WhatsUp\Chat-API-master\src\Registration.php:181 Stack trace: #0 C:\xampp\htdocs\WhatsUp\index.php(19): Registration->codeRegister('175746') #1 {main} thrown in C:\xampp\htdocs\WhatsUp\Chat-API-master\src\Registration.php on line 181
The response that I should be getting is a password (parameter that is called 'pwd'). I also used their two tools that are described in the link.
You can also use WART, you can download from here: /mgp25/WART
Or you can use this online tool: watools
The picture below shows the response that I got.
enter image description here
Why am I getting those errors. Where does this code go wrong? and if the framework doesnt work! what framework is there that works well?
I just need a simple code that sends a simple whatsapp message.
I'm trying to use the Google API PHP Client with the Google Directory API. I went into the Google Developers Console and created a project called google-sync. I then enabled the Admin SDK in the APIs list page. I then selected "Create new Client ID" from the Credentials page, and selected Service Account, and then downloaded the .bin private key that I was prompted to download. I then also clicked on "Generate new P12 key" and downloaded the .p12 file, which was placed in the same directory as the PHP file.
Here's my PHP code (which follows this part of the docs) that is trying to list all users.
<?php
session_start();
require 'vendor/autoload.php';
$SCOPE = 'https://www.googleapis.com/auth/admin.directory.user https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.orgunit';
$SERVICE_ACCOUNT_EMAIL = '<EMAIL ADDRESS>';
$SERVICE_ACCOUNT_PKCS12_FILE_PATH = '<P12 FILE NAME>.p12';
$client = new Google_Client();
$client->setApplicationName('google-sync');
$adminService = new Google_Service_Directory($client);
$key = file_get_contents($SERVICE_ACCOUNT_PKCS12_FILE_PATH);
$cred = new Google_Auth_AssertionCredentials(
$SERVICE_ACCOUNT_EMAIL,
array($SCOPE),
$key);
$client->setAssertionCredentials($cred);
$allUsers = $adminService->users->listUsers();
When I run this code, I get this error:
PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/admin/directory/v1/users: (400) Bad Request' in /projects/google-sync/vendor/google/apiclient/src/Google/Http/REST.php:80
Stack trace:
#0 /projects/google-sync/vendor/google/apiclient/src/Google/Http/REST.php(44): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request))
#1 /projects/google-sync/vendor/google/apiclient/src/Google/Client.php(499): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#2 /projects/google-sync/vendor/google/apiclient/src/Google/Service/Resource.php(195): Google_Client->execute(Object(Google_Http_Request))
#3 /projects/google-sync/vendor/google/apiclient/src/Google/Service/Directory.php(2063): Google_Service_Resource->call('list', Array, 'Google_Service_...')
#4 /projects/google-sync/auth-test.php(20): Google_Service_Directory_Users_Resource->listUsers()
#5 {main}
thrown in /projects/google-sync/vendor/google/apiclient/src/Google/Http/REST.php on line 80
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/admin/directory/v1/users: (400) Bad Request' in /projects/google-sync/vendor/google/apiclient/src/Google/Http/REST.php on line 80
Google_Service_Exception: Error calling GET https://www.googleapis.com/admin/directory/v1/users: (400) Bad Request in /projects/google-sync/vendor/google/apiclient/src/Google/Http/REST.php on line 80
Call Stack:
0.0001 232296 1. {main}() auth-test.php:0
0.0172 2957992 2. Google_Service_Directory_Users_Resource->listUsers() /projects/google-sync/auth-test.php:20
0.0172 2959144 3. Google_Service_Resource->call() /projects/google-sync/vendor/google/apiclient/src/Google/Service/Directory.php:2063
0.3356 2970752 4. Google_Client->execute() /projects/google-sync/vendor/google/apiclient/src/Google/Service/Resource.php:195
0.3356 2971568 5. Google_Http_REST::execute() /projects/google-sync/vendor/google/apiclient/src/Google/Client.php:499
0.7015 2974424 6. Google_Http_REST::decodeHttpResponse() /projects/google-sync/vendor/google/apiclient/src/Google/Http/REST.php:44
When I downloaded the p12 file, I was given a password associated with the private key, but I'm unable to find any documentation on how that password should be included. Is this my problem?
I was facing the same issue. Service account should impersonate a domain admin when it makes the request. In addition, listUsers() expects the domain to be passed as an argument.
Makes sure that you've delegated domain-wide authority to the service account - https://developers.google.com/api-client-library/php/auth/service-accounts
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array($SCOPE),
$key
);
$cred->sub = "admin#domain.com";
//Get All users.
$list = $service->users->listUsers(Array('domain' => 'domain.com'));
//Get one user
$userId = $service->users->get('someuser#domain.com');
I was able to fix this by going into my domain's Admin Console, went to the Manage API client access page under Security, and added the Client Id from the Developer Console and added the scopes I needed for the Directory API.
See this part of the docs for more info.
Hi i am trying to use soap to get results from amazon, and i havent tried this before so i was trying some sample code. The problem is i get an error.
the code is this:
<?php
#Use the NuSOAP php library
//require_once('lib/nusoap.php');
$params->AWSAccessKeyId = AMAZON_API_KEY;
$params->Request->SearchIndex = 'Books';
$params->Request->Keywords = 'php5';
$amazon = new SoapClient('http://webservices.amazon.com/AWSECommerceService /AWSECommerceService.wsdl');
$result = $amazon->itemSearch($params);
echo $result;
?>
and this is the error i get when i run it. thanx for your time
Fatal error: Uncaught SoapFault exception: [aws:Client.MissingParameter] The request must contain the parameter Signature. in C:\wamp\www\amasearch.php:11 Stack trace: #0 [internal function]: SoapClient->__call('itemSearch', Array) #1 C:\wamp\www\amasearch.php(11): SoapClient->itemSearch(Object(stdClass)) #2 {main} thrown in C:\wamp\www\amasearch.php on line 11
Weird. The WSDL doesn't have a signature parameter for any type. BUT, I found this in Amazon dev forums. Recommend you to check it out (also, if you develop using amazon services, keep that resource at hand
https://forums.aws.amazon.com/ann.jspa?annID=483
Looks like security gates for services are now taller and bigger, mate
EDIT: This question link to some example in C#. Maybe it can help you out Amazon (AWS) - The request must contain the parameter Signature
And this is an example in AWS forums with PHP https://forums.aws.amazon.com/message.jspa?messageID=149715