Reading comments for a FB post with Koala gem with Rails 4 - ruby

I have a rails4 app, from which I can put a wall post to logged in users facebook wall. Now what I want to do is read the FB comments for that given post and show then in my application.
I'm using Rails 4 and koala gems. Following is my code
Koala::Facebook::API.new(<user.oauth_token>).get_object("<facebook post id>") but I'm keep on getting this error.
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
And I cannot see any mismatching in the API, strange thing is I remember I'm using the same code about 3-4 weeks back and If I remember correctly it was working fine that time,
it seems like its not an authentication problem because, If I use
Koala::Facebook::API.new(<user.oauth_token>).get_object("me") it works fine.

You will get the GraphMethodException Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api when the user access token you specified does not have access to the Facebook object you are requesting. Here is a bug report with more specifics:
https://developers.facebook.com/bugs/1418832665047223/

Related

Pinterest Authorization failed

We have problem with our prod pinterest application.
After getting token:
"{"access_token": "AabcYgRUKiaBI45HYM72teXO6fZaFQoEhVxkxaREoN3SR-
A4zAAAAAA", "token_type": "bearer", "scope": ["read_public",
"write_public", "read_private", "write_private", "read_relationships",
"read_write_all"]}"
Then we try get user info https://api.pinterest.com/v1/me
with this token Authorization: Bearer AabcYgRUKiaBI45HYM72teXO6fZaFQoEhVxkxaREoN3SR-A4zAAAAAA
and response
"{"status": "failure", "message": "Authorization failed.", "code": 3,
"data": null}"
Application status is In development now. Could it been changed by pinterest? Our dev app works as expected.
I got a response from Pinterest Help.
Feb 2, 09:32 PST
Thank you for providing all the information here. We're getting reports from multiple developers like yourself with the same issue. I'm going to be investigating further with our team and I'll let you know what we find!
No timeline right now on a fix, but I'll let you know when I get one.
"You're receiving that error response because your app has been denied policy approval."
Now only pinterest partners can use publish api.
Thanks for mentioning it in api doc and notification about changes.
I had the same error and wasted a few days trying to figure out why.
I have 2 accounts, user A and B. A is the dev and B is not a collaborator. I think that's why. The document says only collaborators can use the app without being approved by Pinterest.
The returned error message is useless. If it says so, I wouldn't have to create this ticket and the document is also lacking in my opinion.
Also, if non-collaborator can't be authenticated, the access_token step should fail first.
I know that my answer is weird but I was facing this error too. I just copy pasted the url from the Pinterest docs then added the access token then pasted it to the url search field. The mistake which I made is that there were extra spaces in the URL For example
https://api.pinterest.com/v1/me/pins/?
access_token=<YOUR-ACCESS-TOKEN>
&fields=id,creator,note
&limit=1
When you paste it to the url text field the "next line" (\n) would be replaced with spaces like %20. So you should rewrite your url in one line again in your editor or text file then paste it to the chrome url field.
Your final url should be like
https://api.pinterest.com/v1/me/pins/?access_token=<ACCESS-TOKEN>&fields=id,creator,note&limit=1

How to pull pubsub metrics from google api

We are using our own logging solution because stackdriver is su...bpar. I want to pull the metrics on how many unacknowledged messages there are in the pubsub. Started to read the docs on that and they are all over the place.
Found this page:
https://cloud.google.com/monitoring/api/metrics
Despite being under the api it does not describe any api calls, but does contain the description of the metric I want to extract.
Now I am thinking I need to use the monitoring api to extract what I need somehow:
https://cloud.google.com/monitoring/api/ref_v3/rest/
So I use the api explorer to try a couple of methods:
https://developers.google.com/apis-explorer/#search/monitoring/monitoring/v3/monitoring.projects.groups.list
I query and gives me an available url:
GET https://monitoring.googleapis.com/v3/projects/myprojectname/groups?key={YOUR_API_KEY}
I go to my project's console (api & credentials page) and generate an api key without restrictions and paste it in trying to curl.
curl https://monitoring.googleapis.com/v3/projects/myproject/groups?key=myrandomkeylkjlkj
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Why is this happening? How can I get the metrics? I went to the url provided but it explains oauth token creation and has nothing regarding the api keys. I just need to curl things to make sure I am going the right way.
Why does this have to be so hard? Killed several hours of my life trying to get this.
curl -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://monitoring.googleapis.com/v3/projects/myproject/groups

Add Trello Card results in "Error - Malformed URL:"

I'm using ruby-trello gem for creating cards in a Trello list.
For my testing credentials this works fine, for the credentials I use on a production setup I get "Trello::Error - Malformed URL:"
The "Malformed URL" is a direct response from Trello, and I can't get my head around why, and how to fix this.
There is little to no documentation on API response errors by Trello.
Maybe you should watch what you application is sending to Trello.
You should also aread the API that Trello offers and search for the specific request and its response. Also you can probe if the Keys are correct in Trello's Sandbox.
As last option write an issue on Github's gem or ask for assistance to Trello.
Hope it helps.

Google API Explorer and Google Identity Toolkit API not working

I'm trying to explore the Google Identity Toolkit API using the Google API Explorer. The API hints that "No auth required", however when I try to execute a request there is an error message:
This method requires you to be authenticated. You may need to activate the toggle above to authorize your request using OAuth 2.0.
If I try to use the OAuth 2.0 toggle and Authorise the API I get a 400 error:
Error: invalid_request
Missing required parameter: scope
But Google Identity Toolkit API does not declare any scopes.
Please can someone help?
UPDATE:
Further errors I get when using the API Explorer: When trying to execute the getAccountInfo request, I pass a request body with the localId field populated. The response I get is:
400 OK
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "INVALID_SERVICE_ACCOUNT"
}
],
"code": 400,
"message": "INVALID_SERVICE_ACCOUNT"
}
}
Here is the list of Google API scopes:
https://developers.google.com/identity/protocols/googlescopes#oauth2v2
This completely omits Identity Kit.
Tying in a random string into the scopes box produces an error:
I have guessed up that the scope should be https://www.googleapis.com/auth/identitytoolkit by looking at the pattern.
And this scope does not cause an error. So this means it is a valid scope, even though it is undocumented.
That said, I used an API request of:
POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/downloadAccount?fields=kind%2CnextPageToken%2Cusers&key={YOUR_API_KEY}
{
"maxResults": 999
}
And it produced:
200 OK
{
"kind": "identitytoolkit#DownloadAccountResponse"
}
So I will say that I have successfully executed this query while using an undocumented feature. However, it appears that the result from the server is incorrect.
This should answer your question, although the result is simply shining light on a broken server implementation.
I have not reported the bugs / undocumented feature in this answer and would appreciate assistance in that effort.
You may find how to use Google Identity Toolkit from the official site. If you really want to manually try Google Identity Toolkit API, you need to enable the API in your Google Developers Console project, create an ApiKey in the project, and call the API using a command tool like curl. The request syntax should follow the one shown in the Google API Explorer.

Google Verification API 503

The google verification api is giving me a 503 error "An unexpected error occurred. Please try your request again." whenever I try to verify a domain using the TAG_MANAGER method.
This occurs when I try to use the API via the PHP client library and also when I use Google's API explorer. However, if I log in to Google Webmaster Tools and add the site, using Tag Manager as the verification method, I am able to successfully verify myself.
I've attached debugging information from the API explorer below, but it's very light on detail. My support request in the webmaster central forum has been met with deafening silence, but I'm not sure where else to ask.
Request
POST https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=TAG_MANAGER&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.iAC-QBa-7nzvS2lpFFmfcej2Y0suhiWHgS8SivKN9jpYWffljsRV7rbL
X-JavaScript-User-Agent: Google APIs Explorer
{
"site": {
"identifier": "http://unit1-28leanyerdriveleanyer.com",
"type": "SITE"
},
"owners": [
"loboyle#raywhite.com"
]
}
Response
503 Service Unavailable
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "An unexpected error occurred. Please try your request again."
}
],
"code": 503,
"message": "An unexpected error occurred. Please try your request again."
}
}
https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=TAG_MANAGER&key={YOUR_API_KEY}
may need to be
https://www.googleapis.com/siteverification/v1/webResource?verificationMethod=TAG_MANAGER&key={YOUR_API_KEY}
also, a few additional notes
For Google to use your Google Tag Manager container snippet code for Webmaster Tools verification, the code must be placed immediately after the opening tag of your page.
The method you provided is used for verifying a site or domain, be sure you intend to verify a site, because this is what your request currently contains.
This method requires you to be authenticated (OAuth 2.0)
http://code.google.com/apis/accounts/docs/OAuth2.html
Ensure you have visited the following link
http://www.google.com/tagmanager/features.html
I finally stumbled across the fix for this today. The problem was that the service account running the requests needs to have "View and Manage" permissions on the applicable Tag Manager account, not just on the container that is actually being used. Only view access is required to the actual container.
While this isn't exactly desirable (we have 20+ containers for different sites/applications within the one account), it does resolve the problem and allow the Tag Manager site verification to work as intended.
I'm not sure whether the documentation has been changed since I originally had this problem or whether I just missed it. The required permissions are unexpected and the response code is misleading (a 403 would make more sense).
Check if you've enabled "Maintenance Mode" on your domain you're trying to verify using Google. Disable it and you're done.

Resources