I'm attempting to use Google's Natural Language API for PHP, and having followed the instructions, I'm getting an error in the application I've written:
Fatal error: Uncaught Google\Cloud\Core\Exception\ServiceException: {
"error": { "code": 403, "message": "The request is missing a valid API
key.", "status": "PERMISSION_DENIED" } }
I've downloaded the account key file, run the export, but I get the 403 error.
I've created a symbolic link to the file in the project folder, run the export, but I get the 403 error.
I placed the export in the ".bash_profile" file, exited the terminal session, but I get the 403 error.
Provide authentication credentials to your application code by setting
the environment variable GOOGLE_APPLICATION_CREDENTIALS. Replace
[PATH] with the file path of the JSON file that contains your service
account key, and [FILE_NAME] with the filename. This variable only
applies to your current shell session, so if you open a new session,
set the variable again.
When I ran: echo $GOOGLE_APPLICATION_CREDENTIALS the export isn't there, so I ran it again, but I get the 403 error.
I followed the documentation to the letter, and I've gone through it three times, and each time I get the same 403 error.
I see no instructions asking me to store a string value for the API key in the application, but I've found a number of people recommending that, but not provide an example of how or where.
So, some advice would be welcome!
simply do not use an export; while your ~/.bashrc is not apache's .bashrc.
but add the path to the file directly into the PHP code; eg. into a config.php.
or use putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/[FILE_NAME].json');
while preventing HTTP access to that file with .htaccess.
or one can even setup with .htaccess, alike
SetEnv GOOGLE_APPLICATION_CREDENTIALS "/var/www/[FILE_NAME].json"
Related
I'm trying to access a webservice from the prefecture that consolidate commercial invoices, the website provides those 2 certificates .cer and .p7b, I've tried both curl and soap clients with several different options in the params array, but still only get 403 or error on loading key.
Can someone explain me which of the certificates I should use, or if both, which goes in which option and others params needed?
Using curl I at least get a 403 answer (which is something expected without the certificate), but on soap client it only gives SOAP-ERROR: Parsing WSDL even it's the very same URL.
Trying loading the keys leads to:
.CER: "unable to set private key file ... type PEM"
.P7B: "could not load PEM client certificate, OpenSSL error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)"
though the path seems to be correct.
Get same errors using cmd line curl with --cert options (though I tried each cert file individually, is there a way to use both simultaneously?)
I install Directus CMS via git clone successful. In the database 15 tables were created. In /config folder my projectkey.php file were created too.
After installation I want to login with my credentials and get the error "Couldn't reach API".
In PHP Error log -> no entry
In Directus log -> no entry
REST calls:
authenticate/ -> Code 200; Response: data/user
projectkey/ -> Code 200; Response: data/api
ping/ -> Code 200; Response: Pong
In a working instance I have seen that in API Call projectkey/ are more properties. For example data/server is missing in my instance.
Does anyone have any idea what this could be?
Version 8.5.X solved my problem
I had the same error and found the solution in the project's corresponding issue:
Check that you're using HTTPS on webservers and local... that is a new requirement added in 8.7.2 due to a cookie policy change by Chrome et al. If it STILL is an issue, please open a new ticket with exact/specific information. Thanks! 👍
Also, just as a reminder, this is a VERY generic error and could shown for several different root causes. More specific error handling/codes is something we're adding in v9.
Enabling SSL fixed it for me.
I'm trying to create my first SilverStripe website following this tutorial.
So far I have created my website and configured my .env page.
# DB credentials
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_SERVER="localhost"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD=""
SS_DATABASE_NAME="SS_examples"
SS_ENVIRONMENT_TYPE="dev"
I'm not sure entirely how the database is created when creating a site. I checked my databases and I do not have one for it. I can make one manually but I wasn't sure if I should and list it under SS_DATABASE_NAME, or if it will auto-create the db.
I'm assuming this is why when I visit my local site localhost/SSexample/public I get an error saying "The website server has not been able to respond to your request".
Am I missing a step in setting up the site or should I manually create a db named SS_examples?
on a side note my apache server is set up with xampp and my SilverStripe project is in C:/xamp/htdocs.
Steps I took to create site:
Built site in C:\xampp\htdocs by running: composer create-project silverstripe/installer SSexample
Visited my project by going to localhost/SSexample/public
created .env file as listed above
ERROR LOGS
[2019-12-31 22:29:22] error-log.ERROR: Uncaught Exception SilverStripe\ORM\Connect\DatabaseException: "Couldn't run query: SELECT DISTINCT "SiteConfig"."ClassName", "SiteConfig"."LastEdited", "SiteConfig"."Created", "SiteConfig"."Title", "SiteConfig"."Tagline", "SiteConfig"."CanViewType", "SiteConfig"."CanEditType", "SiteConfig"."CanCreateTopLevelType", "SiteConfig"."ID", CASE WHEN "SiteConfig"."ClassName" IS NOT NULL THEN "SiteConfig"."ClassName" ELSE 'SilverStripe\\SiteConfig\\SiteConfig' END AS "RecordClassName" FROM "SiteConfig" LIMIT 1 Table 'ss_lessons.siteconfig' doesn't exist" at C:\xampp\htdocs\SSlessons\vendor\silverstripe\framework\src\ORM\Connect\DBConnector.php line 64 {"exception":"[object] (SilverStripe\\ORM\\Connect\\DatabaseException(code: 0): Couldn't run query:\n\nSELECT DISTINCT \"SiteConfig\".\"ClassName\", \"SiteConfig\".\"LastEdited\", \"SiteConfig\".\"Created\", \"SiteConfig\".\"Title\", \"SiteConfig\".\"Tagline\", \"SiteConfig\".\"CanViewType\", \"SiteConfig\".\"CanEditType\", \"SiteConfig\".\"CanCreateTopLevelType\", \"SiteConfig\".\"ID\", \n\t\t\tCASE WHEN \"SiteConfig\".\"ClassName\" IS NOT NULL THEN \"SiteConfig\".\"ClassName\"\n\t\t\tELSE 'SilverStripe\\\\SiteConfig\\\\SiteConfig' END AS \"RecordClassName\"\n\r\nFROM \"SiteConfig\"\n\r\nLIMIT 1\n\nTable 'ss_lessons.siteconfig' doesn't exist at C:\\xampp\\htdocs\\SSlessons\\vendor\\silverstripe\\framework\\src\\ORM\\Connect\\DBConnector.php:64)"} []
It seems that the installer at localhost/SSexample/public should allow you to configure your database connection settings (and create the database for you).
Getting The website server has not been able to respond to your request error means that you have a problem with webserver - is it running?
EDIT: The website server has not been able to respond to your request is actually Silverstripe's generic error 500 message.
EDIT2: one has to enable dev environment - by adding SS_ENVIRONMENT_TYPE="dev" to .env file and then access localhost/SSexample/public/dev/build to get database created and populated.
First of all, sorry if this question is answered anywhere else, but I could not find the answer I needed so I'll ask again.
I am using laravel to create a REST API which I serve through Docker. Therefore I can reach the API through http://localhost:8888. For example, I have an endpoint /content/fetch/{env_type} which works fine through http://localhost:8888/api/content/fetch/test.
My problem is that I have some images in the (from Laravel root dir) directive /public/images/content/test. I was under the assumption that I would be able to reach these images in my frontend app using <img src="http://localhost:8888/images/content/test/myimage.jpg" /> but this does not work.
I have tried adding public/ before images/... but that did not work either. I also tried the URL to the image in the browser directly, and got 500 Internal Server Error:
Request URL: http://localhost:8888/images/content/test/myimage.jpg
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:8888
Referrer Policy: no-referrer-when-downgrade
Looking in the laravel log I get this: production.ERROR: Uncaught ErrorException: file_put_contents(/var/www/storage/framework/views/ba2564046cc89e436fb993df6f661f314e4d2efb.php): failed to open stream: Permission denied in /var/www/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
I know what it means but it feels strange that I should have to change the permissions for basically the entire vendor folder.
So my guess is that I am approaching this wrong. Does anyone have an idea how I should do this instead?
I want to start by saying I have searched extensively, including google, connect.squareup.com, and Stack Overflow and cannot find an answer to my question. I have posed this question to Square support, and (even though I mentioned I could not access command line and have already done the tutorial mentioned below, I was directed to said tutorial and told to use the command line that I can't use. Here's my problem...
I am trying to set up the square connect API on a webserver for a client. On the webserver, I do not have access to command line (or SSH without an additional cost to the client). The only ways I have found to get the location_id requires command line (as far as I can tell). Is there a way to not have to use command line? Or is there another way to put in the required command without command line access?
Here is what I have done so far:
I read somewhere (can't remember where now) that you can install composer locally, use command line on your machine to install the dependencies needed for square-connect, then move all the files to your server. I have done that to get the files on the server.
My file structure looks like this:
payment-portal/
vendor/
composer/
square/
autoload.php
composer.json
composer.json
composer.lock
composer.phar
locations-test.php
process-card.php
The locations-test.php contains:
<?php
require 'vendor/autoload.php';
$access_token = "ACCESS_TOKEN";
$location_api = new \SquareConnect\Api\LocationApi();
echo $location_api->listLocations($access_token);
Note: ACCESS_TOKEN has been replaced with my personal access token.
Of coarse, if I access this file at mywebpage.com/payment-portal/locations-test.php, I get a blank page.
Also, I am not getting any errors in the error log.
The way to get locations is lined out here.
Under "Retrieving your location IDs." I am OK up until this point, but I cannot use command line in my server to use the code:
php locations-test.php
What are my other options to get the location_id? What am I missing?
Thanks in advance for any help or direction!
According the php-sdk you're using for connecting to the square API, the required format for $access_token should be "Bearer YOUR_ACCESS_TOKEN" no just your access token.
/**
* #param string $authorization The value to provide in the Authorization header of
* your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
Try using this instead and see if it works.
require 'vendor/autoload.php';
$access_token = "Bearer ACCESS_TOKEN";
$location_api = new \SquareConnect\Api\LocationApi();
echo $location_api->listLocations($access_token);
Of course, don't forget to replace the ACCESS_TOKEN part with your own access token.