Some Hangout's API methods are not working - hangouts-chat

I'm building a chat bot using Hangouts API and some of the API methods are not working, I receive the response:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
For example, when I get the spaces my bot is a member, it returns all spaces just fine. Then I try to use some of these spaces id to get the member list, and it returns that the request contains an invalid argument. I can't see what I'm doing wrong...
The token can't be the issue because it works fine to get the spaces.
EDIT: The create message method returns a different error:

I figured it out... My company have a lib to generate a token for google's apis and the email that was used in the request was the current user email, but, for the bot it must be used the email associated with the service account, I switched that and it started working. I think it shouldn't generate a token case the credentials are not valid because I couldn't figure out what was wrong.
Source where I found this: https://developers.google.com/hangouts/chat/how-tos/rest-api#authorizing_the_service_account

Related

how to interpret ERROR_UNSUPPORTED_NAMESPACE on getGroups?

I'm troubleshooting some errors from the Sonos API, where calls to getGroups result in HTTP 404. Here's a sample response:
{
"errorCode": "ERROR_UNSUPPORTED_NAMESPACE",
"reason": "Unexpected error"
}
And here's the corresponding request (with token and household_id redacted):
curl -H "Authorization: Bearer <token>" "https://api.ws.sonos.com/control/api/v1/households/<household_id>/groups"
This error is happening repeatedly for this particular token, which otherwise appears correct and was used to retrieve the household_id used above.
For most users, the same code path and request yields HTTP 200 and a collection of players and groups.
I'm getting the exact same error for 2 users and I can't replicate it on my end.
The documentation says;
When your app sends a namespace that is not recognized by the player,
you’ll receive an ERROR_UNSUPPORTED_NAMESPACE error response. Note
that namespaces are case-sensitive.
For example, if you misspelled the namespace, the player responds with
an ERROR_UNSUPPORTED_NAMESPACE in the global namespace:
{ "errorCode": "ERROR_UNSUPPORTED_NAMESPACE" }
https://developer.sonos.com/reference/types/globalerror/
Like you, I have not spelled anything incorrectly and as its working correctly for the vast majority of users. Again, I can get households for these particular users but not groups.
I am at a complete loss but if I find out the reason I'll follow up.
Thanks, Paul

Xero API Forbidden getting Item

This only happened in the past few days that I am having this issue but only for getting an Item. I can get contacts and get branding themes. Therefore, tenand id is working and accesstoken.
This is the endpoint when i'm getting item:
https://api.xero.com/api.xro/2.0/Items/SHO B 100 S
Response:
{
"Type": null,
"Title": "Forbidden",
"Status": 403,
"Detail": "AuthenticationUnsuccessful",
"Instance": "94aa22f4-6ba1-43f6-8f76-699befb1b1f3",
"Extensions": {}
}
And this is the scope:
offline_access accounting.transactions openid profile email accounting.contacts accounting.settings
I am not sure what had changed but everything is working except getting an item. Please tell me how can I fix this and what causes the issue. Thank you so much in advance.
Couple of things you can confirm to debug this.
You have a valid, refreshed access_token (Can you make api calls to any other endpoints? is the JWT's "exp" > than current time?)
Did you add the scope after you generated the initial token? (To test, completely clobber the token set, and re-generate a new one going through the OAuth2 flow)
The query looks correct. The screenshots are when I query an item with a code that exists and doesn't. You should get a 404 if not found not a 401 so I def think its something in #1 or #1

invalid signature for travelpayouts hotel api

I am trying to send a request to travelpayouts hotel search API, Two days ago I have been trying to get a result using the postMan program but a message appears that there is an error in the signature, although I followed the same instructions mentioned in the documentation for the API, if someone used this API before that please ask me to help me
Api link that I have used
Error message:
{
"message": "Invalid signature",
"status": "error",
"errorCode": 3
}
You could send your signature string to support#travelpayouts.com and mention a link to this question on SO, and we'll take a look at it and suggest how to make it work. As the signature string has your API token, it's better not to post it here.

google oauth2 discovery return wrong token_endpoint

Here is the google oauth2 discovery url.
https://accounts.google.com/.well-known/openid-configuration
And in the response, it looks like this
{
"issuer": "https://accounts.google.com",
"authorization_endpoint":"https://accounts.google.com/o/oauth2/v2/auth",
"token_endpoint": "https://oauth2.googleapis.com/token",
"userinfo_endpoint": "https://www.googleapis.com/oauth2/v3/userinfo",
"revocation_endpoint": "https://oauth2.googleapis.com/revoke",
"jwks_uri": "https://www.googleapis.com/oauth2/v3/certs",
...
The token_endpoint in the google document here https://developers.google.com/identity/protocols/OAuth2WebServer#exchange-authorization-code said it should be https://www.googleapis.com/oauth2/v4/token.
Maybe recently the token_endpoint is updated, but when I use https://oauth2.googleapis.com/token this one to exchange token with code., I will get an error response.
{ "error": { "code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT" } }
And if I use https://www.googleapis.com/oauth2/v4/token to do the same thing, everything is fine.
Is there anything changed in google identify platform? Thanks!
The OAuth endpoint has been updated a number of times over the last five years. I normally follow the one i the discovery doc but your example shows that that is not always the best course of action all of the time.
I have never heard of google shutting down old endpoints i suggest you use the one that works. As a side note i will contact Google to see if i can get some feed back as to why one call worked and the other didnt.

Google Surveys api - INVALID_CREDENTIALS

I try get surveys results through the api, but I am still getting an errors.
I am able to get google calendar events, but when I try get list of surveys, or results (https://www.googleapis.com/surveys/v2/surveys/{survey_ID}/results), I am getting:
"domain": "global",
"reason": "INVALID_CREDENTIALS",
"message": "User must be authenticated to make this call. Request Id: 5a73195500ff0c64532dccb0ef0001737e3430322d747269616c320001707573682d30312d33312d72313100010163",
"locationType": "header",
"location": "Authorization"
}
It looks like I have bad access token, but with same token and method, I get for example calendar events.
It looked like I have no scope, but when I issue this request https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={valid_token} I get correct answer:
"issued_to": "822311642112-***********.apps.googleusercontent.com",
"audience": "822311642112-***********.apps.googleusercontent.com",
"scope": "https://www.google.com/calendar/feeds/ https://www.googleapis.com/auth/surveys",
"expires_in": 2983,
"access_type": "offline"
I have enabled Survey api in my account. I am running this code from visual foxpro desktop application over windows object Microsoft.XMLHTTP
Any idea what am I doing wrong?
EDIT:
This is not duplicate of this question because my authentication credentials work fain with calendar, but not working with surveys.
It looks like Maia Werbos has correct answer for me, now I am getting response that request is correct (status: 200), but response contains just requestId.
Maia thank you very much.
Your request shows that you have the following two OAuth scopes enabled:
https://www.google.com/calendar/feeds/
https://www.googleapis.com/auth/surveys
But you also need to have the email scope enabled to use the Surveys API (see the Surveys API Getting Started Guide for more info):
https://www.googleapis.com/auth/userinfo.email