google drive api client(python) update error - google-api

not working only update function.
https://developers.google.com/apis-explorer
and good work same parameter on api explorer.
update file is from cloud domain file. is that reason?
Traceback (most recent call last):
File "E:/cygwin64/home/socia/workspace/language/python/wc_py2_rule/src/main/python/package_name/module/sotrage/google_folder_changer.py", line 230, in <module>
main(sys.argv[1:])
File "E:/cygwin64/home/socia/workspace/language/python/wc_py2_rule/src/main/python/package_name/module/sotrage/google_folder_changer.py", line 101, in main
set_seed_file_on_folder(file_info, folder, service)
File "E:/cygwin64/home/socia/workspace/language/python/wc_py2_rule/src/main/python/package_name/module/sotrage/google_folder_changer.py", line 142, in set_seed_file_on_folder
removeParents=file_info['parents']).execute()
File "E:\cygwin64\home\socia\workspace\language\python\wc_py2_rule\venv\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "E:\cygwin64\home\socia\workspace\language\python\wc_py2_rule\venv\lib\site-packages\googleapiclient\http.py", line 851, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/drive/v3/files/... returned "File not found: [u'file_id'].">
file_id is replaced on error cause of security
and link content is below.
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}

"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
Means that you are making a call to a private method without authenticating as a user first. If you want to see user data you must be authenticated as a user who has access to that data. Check your code and make sure that you have your authentication setup correctly and the user has logged in before you try and run the method in question.

Related

google-api-nodejs-client - Service Account credentials authentication issues

I am trying to use the google-api-nodejs library to manage some resources in the google Campaign Manager API.
I have confirmed that we currently have a project configured, and that this project has the google Campaign Manager API enabled (see screenshot at the bottom).
I have tried several ways of authenticating myself (particularly API keys, OAuth2, and Service account credentials). This question will focus on using a Service Account for authentication purposes.
Now, I have generated a new service account keyfile (see screenshot at the bottom)), and I configured my code as follows, following the service-account-credentials section of the library's repo. I've also extended the auth scope to include the necessary scope according to this endpoint API docs
import { assert } from "chai";
import { google } from "googleapis";
it("can query userProfiles using service account keyfile", async () => {
try {
const auth = new google.auth.GoogleAuth({
keyFile:
"/full-path-to/credentials-service-account.json",
scopes: [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/dfatrafficking",
"https://www.googleapis.com/auth/ddmconversions",
"https://www.googleapis.com/auth/dfareporting",
],
});
const authClient = await auth.getClient();
// set auth as a global default
google.options({
auth: authClient,
});
const df = google.dfareporting("v3.5");
const res = await df.userProfiles.list({});
console.log("res: ", res);
assert(true);
} catch (e) {
console.error("error: ", e);
assert(false);
}
});
This results in the following error:
{
"code": 403,
"errors": [
{
"message": "Version v3.5 is no longer supported. Please upgrade to the latest version of the API.",
"domain": "global",
"reason": "forbidden"
}
]
}
This is an interesting error, because v3.5 is the latest version of that API (as of 14 April 2022) (This page shows the deprecation schedule: https://developers.google.com/doubleclick-advertisers/deprecation. Notice that v3.3 and v3.4 are deprecated, while v3.5 is not.)
In any case, using a different version of the dfareporting API still result in error:
// error thrown: "Version v3.5 is no longer supported. Please upgrade to the latest version of the API."
const df = google.dfareporting("v3.5");
// error thrown: "Version v3.4 is no longer supported. Please upgrade to the latest version of the API."
const df = google.dfareporting("v3.4");
// error thrown: 404 "The requested URL <code>/dfareporting/v3.3/userprofiles</code> was not found on this server"
const df = google.dfareporting("v3.3");
// Note 1: There are no other versions available
// Note 2: It is not possible to leave the version blank
const df = google.dfareporting();
// results in typescript error: "An argument for 'version' was not provided."
I also tried to query the floodlightActivities API, which failed with an authentication error.
// const res = await df.userProfiles.list({});
const res = await df.floodlightActivities.list({
profileId: "7474579",
});
This, in it's turn, results in the following error:
{
"code": 401,
"errors": [
{
"message": "1075 : Failed to authenticate. Google account can not access the user profile/account requested.",
"domain": "global",
"reason": "authError",
"location": "Authorization",
"locationType": "header"
}
]
}
Now, my question is:
am I doing something wrong while trying to authenticate using the service account credentials?
Or, is it possible that these endpoints do not support service-account-credentials?
Or, is something else going wrong here?

Malformed UTF-8 characters, possibly incorrectly encoded with Guzzle/Http

I have an API created for export records in xlsx. It is working fine when I call the API directly but if I am using Guzzle/Http to call the API and this was tested using Postman, I get the following error:
"message": "Malformed UTF-8 characters, possibly incorrectly encoded",
"exception": "InvalidArgumentException",
"file": "C:\\xampp\\htdocs\\borneoshop-admin-laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\JsonResponse.php",
"line": 75, ......
Is there any additional configuration I will have to set?
Please help. Thanks.
Edit
I have 2 laravel API projects, for example, A and B. The excel export API (/a/export) has to be called in another laravel API (/b/download) with Guzzle/Http. Using Postman, I was testing both APIs and the "/a/export" API was working fine but if I called "/b/download" which I am using Guzzle/Http here with codes,
$client = new \GuzzleHttp\Client();
$res = $client->post($url, ['form_params' => $parameter]);
$content = $res->getBody()->getContents();
return $content;
I am getting the error response as shown above.

Use Laravel Socialite user returns missing authorization_code

I'm using Laravel Socialite to login with SuperOffice API. Have only just added the provider as a pr but testing it already. I'm using the provider superoffice locally and inside a package superoffice-api I'm creating. Have added both packages to composer.json in the Laravel app:
"repositories": [
{
"type": "path",
"url": "./packages/superoffice-api"
},
{
"type": "path",
"url": "./packages/superoffice"
}
]
Also added the superoffice Socialite provider in the superoffice-api composer.json in the same way.
The login process is working but the problem starts when trying to use the user for other API calls. What I mean with this is on the callback I can do the following:
public function superofficeCallback(Request $request): RedirectResponse
{
$user = Socialite::driver('superoffice')->stateless()->user();
return redirect()->route('dashboard.index')->with([
'message' => 'Loggedin with SuperOffice as '.$user->name,
'success' => true,
]);
}
This shows the $user->name as expected. Now when trying to call Socialite::driver('superoffice')->stateless()->user() in the superoffice-api package I get the following error message:
GuzzleHttp\Exception\ClientException: Client error: POST https://sod.superoffice.com/login/common/oauth/tokens resulted in a 400 Bad Request response:
{ "error": "invalid_request", "error_description": "missing authorization_code"}
It doesn't matter if called in a method or in the __construct() of a class.
So my question is how can I use a Socialite provider superoffice user in a package superoffice-api? This is needed to get the access_token. Can imagine that because Socialite is called in a package some sort of reference is missing.
The problem here is that the access_token and refresh_token need to be stored in some other way in the callback function. When stored for example in the database you're able to use the tokens anywhere.

Error executing “PutObject” on AWS

I am trying to read .png file from storage path of laravel and upload the same into amazon s3, but i'm getting this below issue:
{
"code": 422,
"status": "error",
"data": {
"exception": "Error executing \"PutObject\" on \"https://s3.amazonaws.com/mrxmms/123/12345_ach.png\"; AWS HTTP error:
count(): Parameter must be an array or an object that implements
Countable"
},
"message": "Unprocessable Entity" }
Here is my sample code:
$dir = storage_path('uploads'); $image_val = $dir. '/'
."product.png";
$image_load =
Storage::disk('s3')->put("123/12345.png",file_get_contents($image_val));
Can someone please help me? Thanks in advance!!
This issue hit me recently when using Guzzle in version 6.2.1 and AWS SDK in version 3.*
Updating Guzzle to 6.3.* solved the issue for me.
composer require guzzlehttp/guzzle:6.3.*
Hope that helps.

Youtube playlistItems list API sometimes works, sometimes throws 404

I have retrieved upload Id from a channel as shown here(https://www.youtube.com/watch?v=RjUlmco7v2M&t=2s),
and using it as playlitstId here https://developers.google.com/youtube/v3/docs/playlistItems/list#try-it
Sometimes it gives 200, sometimes 404,
Response {_body: "{↵ "error": {↵ "errors": [↵ {↵ "domain":
"yo…003c/code\u003e parameter cannot be found."↵ }↵}↵", status: 404,
ok: false, statusText: "OK", headers: Headers…}
Additional info:
I have selected part as contentDetails,id,snippet
maxResults 50
You may check in this documentation the possible reasons why you got a 404 error in PlaylistItems: list. These methods could also return errors listed in the Common errors section.
notFound (404)
playlistNotFound
The playlist identified with the request's playlistId parameter cannot be found.
notFound (404)
videoNotFound
The video identified with the request's videoId parameter cannot be found.
required (400)
playlistIdRequired
The subscribe request does not specify a value for the required playlistId property.
However, if it doesn't solve your issue and you think that it is a bug, you can file a report here.

Resources