undefined method 'createtoken'.intelephense(1013) laravel 8 API - undefined

I have added use Laravel\Passport\HasApiTokens; and use HasApiTokens in user model. Still intelephense is unable to recognise it in vs code. Also in postman when i run it it showns me error "message": "Personal access client not found. Please create one.", "exception": "RuntimeException", "file": "C:\\xampp\\htdocs\\project\\vendor\\laravel\\passport\\src\\ClientRepository.php", How can i solve it?
My line for creating token is $token = Auth::user()->createToken("user_token")->accessToken;

Run this command.
php artisan passport:client --personal

Related

ChainableTemporaryCredentials getPromise and Missing credentials in config, if using AWS_CONFIG_FILE

I have an node application deployed in GCP.
The application includes code to access ressources in AWS-cloud.
For this purpose it uses the aws-SDK with ChainableTemporaryCredentials.
The relevant code lines are...
const credentials = new ChainableTemporaryCredentials({
params: {
RoleArn: `arn:aws:iam::${this.accountId}:role/${this.targetRoleName}`,
RoleSessionName: this.targetRoleName,
},
masterCredentials: new WebIdentityCredentials({
RoleArn: `arn:aws:iam::${this.proxyAccountId}:role/${this.proxyRoleName}`,
RoleSessionName: this.proxyRoleName,
WebIdentityToken: token,
}),
})
await credentials.getPromise()
The WebIdentityToken was received from google and looks good.
At AWS-side I created an proxy-role (the line from masterCredentials RoleArn).
However at runtime I get the error:
Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
I do not understand this error. Because my application runs in GCP and I use temporary credentials I do not understand why I should use aws-credentials in form of an credentials file or environment variables like AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY. I thought the idea to use ChainableTemporaryCredentials is NOT to have direct aws-credentials. Right?
You can see the public code at:
https://github.com/cloud-carbon-footprint/cloud-carbon-footprint/blob/trunk/packages/aws/src/application/GCPCredentials.ts
and documentation regarding env-variables at:
https://www.cloudcarbonfootprint.org/docs/configurations-glossary/
Any help which leads to understanding of this error message is welcome.
Thomas
Solved it. "Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 was totally misleading." In reality it was a problem with the field-names in the GCP-JWT-token und the policy in aws. See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_iam-condition-keys.html#ck_aud

TYPO3 CMS Exception 1256475113 in Extension Manager

I just made a new installation of Typo3 8.7.20, and when I enter the Extension Manager to download extensions I get the following Error Message:
"Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1256475113: The argument "arguments" was registered with type "array", but is of type "integer" in view helper "TYPO3\CMS\Fluid\ViewHelpers\Widget\UriViewHelper". | InvalidArgumentException thrown in file /var/www/clients/client4/web9/web/neu/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper.php in line 356. Requested URL: /typo3/index.php?M=tools_ExtensionmanagerExtensionmanager&moduleToken=--AnonymizedToken--&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=ter&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List "
Another thing I recognized is that the "Function" to Create multiple pages is not working, the screen looks if some words are missing and when I click on create pages I get the message "no pages created".
What is wrong with my installation?
Can you check if you have cUrl installed? Maybe the extension-manager is not able to load data from TER?

Proxy request on firebase

I have created a project using Ionic and deployed it as a PWA to firebase. I have got around CORS utilising a proxy to call google maps api sevices. This works locally however once deployed this is no longer the case.
The response I am getting on the server is:
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at XMLHttpRequest.l (https://atomic-affinity-127705.firebaseapp.com/build/vendor.js:1:312114)
at t.invokeTask (https://atomic-affinity-127705.firebaseapp.com/build/polyfills.js:3:15660)
at Object.onInvokeTask (https://atomic-affinity-127705.firebaseapp.com/build/vendor.js:1:26996)
at t.invokeTask (https://atomic-affinity-127705.firebaseapp.com/build/polyfills.js:3:15581)
at r.runTask (https://atomic-affinity-127705.firebaseapp.com/build/polyfills.js:3:10834)
at e.invokeTask [as invoke] (https://atomic-affinity-127705.firebaseapp.com/build/polyfills.js:3:16794)
at p (https://atomic-affinity-127705.firebaseapp.com/build/polyfills.js:2:27648)
at XMLHttpRequest.v (https://atomic-affinity-127705.firebaseapp.com/build/polyfills.js:2:27893)
"Http failure during parsing"
When looking at the text field I get the contents of my index.html page being parsed. Starting with the Doctype explaining why the error fails on <.
Ionic.config.json has the following:
"proxies": [{
"path": "/api",
"proxyUrl": "https://maps.googleapis.com/"
}]
and is called as such:
/api/maps/api/place/nearbysearch/ ....etc
Any help would be greatly appreciated.
For those that are interested in this solution, I ended up utilising the js libraries provided by Google. The alternative to get around this is create a functions set on firebase and run express to do the calls for with the appropriate CORS headers however I didn't want to add extra calls in.

Issue with Google-API-PHP Client, getting error when running the quick start script

I am facing an issue with quickstart php script here: https://developers.google.com/drive/v2/web/quickstart/php
When I run the script first time, it executes perfectly and the access token is stored in a file called: drive-php-quickstart.json
When I run the script second time, it gives me the error:
Error start:
Notice: Undefined index: expires_in in \google-api-php-client\src\Google\Client.php on line 485
Fatal error: Uncaught exception 'LogicException' with message 'refresh token must be passed in or set as part of setAccessToken' in
Error end:
My assumption is that access token been saved in the file is not in the right format.
Current format:
ya29.CODE-oN_Bearer36001/_ANOTHER-CODE-ANOTHER_ANOTHER_CODE
As you can see, it does not contain the variable "expires_in"
Any suggestions where I am going wrong ? I am running the script as it is, with no modifications.
I've debugged it.... The person who wrote it made a mistake by not calling json_encode before writing the auth result to the token.json file.
You can fix it by adding json_encode on line 45.
So...
file_put_contents($credentialsPath, $accessToken);
...should be:
file_put_contents($credentialsPath, json_encode($accessToken));
I've submitted feedback so hopefully it'll be fixed.
edit: same issue happens for the token refresh call in that same method
edit2: Here's my related comment in a Github discussion and an answer from Google: https://github.com/google/google-api-php-client/issues/263#issuecomment-186557360
I suggested something along the following lines:
if ($client->isAccessTokenExpired()) {
$refreshToken = $client->getRefreshToken();
$client->refreshToken($refreshToken);
$newAccessToken = $client->getAccessToken();
$newAccessToken['refresh_token'] = $refreshToken;
file_put_contents($credentialsPath, json_encode($newAccessToken));
}
Instead of:
// Refresh the token if it's expired.
if ($client->isAccessTokenExpired()) {
$client->refreshToken($client->getRefreshToken());
file_put_contents($credentialsPath, $client->getAccessToken());
}
Google has updated their PHP Quickstart, with an improved method to handle this:
// Exchange authorization code for an access token.
$accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
$client->setAccessToken($accessToken);
// Refresh the token if it's expired.
if ($client->isAccessTokenExpired()) {
$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
file_put_contents($credentialsPath, json_encode($client->getAccessToken()));
}

Unknown authentication strategy "local", nodejs-mysql

I am working on Angular-node-mysql application. I am trying to implement login functionality using passport.js. I am getting error "unknown authentication strategy "local". I checked the other posts online, but failed to fixed the issue. I used the reference :
Github reference
my code : server.js
Error I see on browser:
I am unable to figure out my mistake
You named your strategy 'local-login'. Try changing
app.post("/login", passport.authenticate('local') .....
to
app.post("/login", passport.authenticate('local-login') .....