google cloud api unknown name "body_resource" - google-cloud-platform

I want to get the IAM policy for a user using
https://cloud.google.com/resource-manager/reference/rest/v1/projects/getIamPolicy
When I enter a userid into the resource field though, I get
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"body_resource\": Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"body_resource\": Cannot find field."
}
]
}
]
}
}
What should I put in the request body to get the IAM policy for this user? Or is the error wrong and Users just dont have resource policies like this?
EDIT: To be clear, I get this error no matter what I put in the resource field

I think right now the UI for this API is broken and doesn't work from the browser, I get the same error.
You can however try calling it from the API explorer, or by making the call using the api client libraries as shown in the examples at the bottom of the page you linked.

The in-page explorer did have a bug, but the fix is rolling out now.
This was caused by an issue with how the GAPI library calls APIs with a parameter called 'resource', so it should only have affected pages with such a parameter in their method.

Related

How to resolve "Access to requested resource is denied"?

I am getting the following when sending a marketplaceParticipations request to sellers/v1/marketplaceParticipations via Postman after following instructions and examples provided at https://developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api
{
"errors": [
{
"message": "Access to requested resource is denied.",
"code": "Unauthorized",
"details": ""
}
]
}
We have registered a self-authorized app client in Draft status which has a user ARN IAM attached as described at https://developer-docs.amazon.com/sp-api/docs/registering-your-application.Ï
I've checked the inline and role policies for the ARN IAM. They are exactly as described at https://developer-docs.amazon.com/sp-api/docs/creating-and-configuring-iam-policies-and-entities#step-4-create-an-iam-role.
We are able to successfully request an LWA access token following the docs at https://developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api#step-1-request-a-login-with-amazon-access-token.
Please check that the roles of the user you are using allow to make request to that endpoint in your dev profile at https://sellercentral.amazon.com/
As far as I know, the getMarketplaceParticipations doesn't need a Restricted Data Token (RDT). So you must be able to solve it by giving the user the correct roles.
I was able to get them using Postman. It is a good way to check that the request is correctly built and not a programming issue.

Unable to correctly call google cloud identity apis

Hi I'm trying to use google cloud identity apis in order to retrieve the list of users registered with CI under my organization. I've tried first with this api https://cloud.google.com/identity/docs/reference/rest/v1/groups/list passing the organization ID as parent field but I got the following error:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
I've also tried with https://cloud.google.com/identity/docs/reference/rest/v1/groups/get passing "groups/" as name but this time I got this output:
{
"error": {
"code": 403,
"message": "Error(2017): User does not have permission to get group 'groups/abcpi1tg3uve2ab' (or it may not exist).",
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ResourceInfo",
"resourceType": "cloudidentity.googleapis.com/Group",
"resourceName": "groups/abcpi1tg3uve2ab",
"owner": "domain:cloudidentity.googleapis.com",
"description": "Error(2017): User does not have permission to get group 'groups/abcpi1tg3uve2ab' (or it may not exist)."
}
]
}
}
and I'm using the same account I use to log into Admin console.
I'm testing the apis via apis explorer with a superadmin user.
Can anyone please tell me what I'm doing wrong and what the "parent" required field exactly mean in the first api?
There seem to be some issue with this cloud identity methods, I was not able to make them work properly.
I suggested some other ways that has been tested to retrieve this groups information:
I ran some tests and it seems there is some issue with cloud identity Method to get the groups, please use this other method from Gsuite to get the Groups from Identity.
Also I tes some interesting function to retrieve this groups that will help you, please take a look to it.
I successfully find a way to use it.
For instance, I tried to use membership lookup, and after struggling a bit.
You have to uncheck API Key.
And group_id is not the email's group but the id that you can find in the Admin console. Look like something like that: 028g0dx5903cNq

AWS API gateway Stage name error handling

Consider I have created an API using with AWS API gateway with the following URL
https://0abcgdefg1.execute-api.ap-northeast-1.amazonaws.com/Employee/.
is it possible to create an error message if the end user tried a nonexisting stage name? For eg
https://0abcgdefg1.execute-api.ap-northeast-1.amazonaws.com/Employee1/
is it possible to give some error information like below?
{
"errors": [
{
"message": "Stage name Employee1doesn't exist",
"type": "InvalidStageError"
}
]
}
No APIGW do not support returning custom error information when stage does not exits.
I am also wondering why you need to return this error message to API user ? can you provide details about your use case ?

API Key not valid error when trying to access Google cloud vision api

I am trying to test out the vision API and have uploaded some images to Google cloud storage and have created a browser app that requests the cloud api to process them.
I have a client_id file that I downloaded from the Google developers console. This has a client_id value that I am using as my api key.
I make a request to
https://content-vision.googleapis.com/v1/images:annotate?alt=json&key=414712345643-cln7htsuv78jr9i64v8v7g6cnhm3ccff.apps.googleusercontent.com
(api key altered)
and post the request:
{
"requests": [
{
"image": {
"source": {
"gcsImageUri": "https:\/\/console.cloud.google.com\/m\/cloudstorage\/b\/estoril_test\/o\/AI4C3160.JPG"
}
},
"features": [
{
"type": "LABEL_DETECTION",
"maxResults": 1
}
]
}
]
}
but I get an error:
{
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/414754136843/apiui/credential"
}
]
}
]
}
}
I have authorized that api key for the cloud vision api so what am I doing wrong? I did try the curl example in the demo but I keep getting
Protocol https not supported or disabled in libcurl
I tried adding double quotes as some research suggested I should but still no luck.
For the "API key not valid" issue, it appears that you are using a Server key, but you need to use a browser key. The Vision API Getting Started page has detailed screenshots, as well as a curl example.
The second issue you are likely to encounter is that the gcsImageUri is the incorrect format. According to the Vision API reference docs the image URI must be in the form "gs://bucket_name/object_name", so in your case: something like: "gs://storil_test/AI4C3160.JPG"
Another problem that can be encountered with a KEY not working is that a particular service has not been added to the project you are trying to work with. That will give this same response.
Problem is resolved.
After generating credentials, Click on 'Create Credentials' Drop down and choose - 'API Key'; the generated API Key will be used..
key=414712345643-cln7htsuv78jr9i64v8v7g6cnhm3ccff.apps.googleusercontent.com
This is "ID client Oauth" key.
sAjnhsejklfynGiuhYGBYUGDYGziodzdCfhAO7qPY
This is an exemple of valid API KEY
To create API KEY follow this link :
https://support.google.com/cloud/answer/6158862?hl=en

Getting "unsupported GET request" from public_profile info

I'd like to know my Facebook ID but the "official" way of doing that
http://graph.facebook.com/{user} (obviously with my userid) gives an unsupported GET error:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
Why is not working? The documentation says the the userid is always part of the public_profile. Are there any other ways of doing that?
"ugol70" is not your id, it´s your username. You can´t use the username anymore. Only use the "App Scoped ID" you get after authorizing (either directly in the authorization process or with the /me endpoint).
..and ALWAYS use an Access Token for API calls. See the following links about Access Tokens, for example:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/