oAuth request token issue Codeigniter/Magento2 - php

Been going around in circles with this and not getting a definitive answer... The error I am facing is:
oauth_problem=Cannot+create+request+token+because+consumer+token+is+not+a+verifier+token
Everything is correctly set with regards to my oAuth request header and sending to magento path /oauth/token/request. I have, even though the documentation says it doesn't require it (but for testing) added the verifier string to the request...
Pasting the code in here would make for a very long post and the code is working fine albeit it seems something is missing? If I use the verifier string in the consumer key it gives me the following error instead:
oauth_problem=Consumer+key+is+not+the+correct+length
Does anyone have any nuggets of information that the following links are missing that's tripping me up?
http://devdocs.magento.com/guides/v2.0/howdoi/webapi/integration.html
http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-oauth.html#pre-auth-token
I have found this on github, some people have seemed to work it out but not forthcoming with the details of how? github

This error occurs if you already have a request token created in Magento DB table oauth_token (if you're like me and developing an app and raising requests over and over to test), clear this table of its entries (request and verify) before retrying and this error won't appear.
2020 UPDATE:
This answer is still valid. Sometimes you may need to clear the Magento cache also after clearing the oauth_token table entries.

Related

Troubles with uservoice 3-legged OAuth

I've followed a couple of different guides on this, but I can't seem to get my head around the way in which Uservoice 3-legged OAuth works.
The guides I've followed:
https://github.com/uservoice/uservoice-php#verifying-a-uservoice-user
https://developer.uservoice.com/docs/api/php-sdk/ (See: Associating your users with their UserVoice profiles)
I can successfully redirect the user to the uservoice auth screen, which asks for permission, and on clicking "Allow Access" they are taken back to the correct callback URL, however this is where their documentation fails...
Following exactly what they suggest, I do the following:
$access_token = $client->login_with_verifier($_GET['oauth_verifier']);
However this fails of course unless I have a $client, so, I make that as I did on the last request... but then it complains that UserVoice\Client::$request_token isn't set on line 130 (see here).
And the only way to set that variable, is to recreate the auth link... which generates a whole new OAuth process, so it inevitably fails authentication.
I'm wondering if anybody knows how I can work around this?
Was able to put this down to a small bug in the package, and have submitted a pull request to fix this
https://github.com/uservoice/uservoice-php/pull/4

Unable to search for specific term via Graph API

It seems Facebook is preventing search of a specific term.
As part of a site we are launching, had planned to query Facebook for the term #bestsummerever.
So the request to Graph API using an app access token for public data is the form:
/search/?q=%23bestsummerever
This now gives me the following error:
OAuthException
An unexpected error has occurred. Please retry your request later.
The error is new sometime between last week and this week.
I can query other "hashtags" with no issue, all of the following work:
/search/?q=%23bestsummereve
/search/?q=%23bestsummereverr
/search/?q=%23bestsummer
So it seems like I am strictly being prevented from querying #bestsummerever. This seems to be consistent regardless of what app I make the request with.
There does not seem to be any documented reason for this issue.
Can be reproduced using any app access token on the Facebook Graph Explorer. Really hoping this is some kind of small oversight on my part, but seems more like Facebook has some kind of restriction on that specific term.
First of all, Facebook requires that you provide an User Access Token if you search for obejcts other than places and pages (see https://developers.facebook.com/docs/graph-api/using-graph-api#search).
Apparently there IS some strange behaviour with your desired hashtag:
GET /search?q=%23selfie&type=post
works fine, whereas
GET /search?q=%23bestsummerever&type=post
produces an error. But
GET /search?q=bestsummerever&type=post
works for me. Strange, but maybe you can go on without the hashtag for now.

Setting a groups cover image using the Facebook Graph API

I've been visiting this forum for years, but this is my first ever question. Any help would be appreciated!
I am writing a web service to pass groups from one application into Facebook and invite the authorised people into them and set a nice pretty cover photo that is generated and stored within the application.
The group creation works splendidly after a fair old bit of head scratching, however, when I try to set the cover image, I am getting a rather useful error message back as below.
OAuth "Facebook Platform" "unknown_error" "An unknown error has occurred."
It's a PHP application on Code Igniter. According to Facebook's delightfully accurate API documentation, this is a simple matter of a cUrl post to 'graph.facebook.com/$groupId' passing the same auth token I just used to create the group and perform the invites and a single JSON encoded parameter of 'cover_url' => $urlOfImage .
A simple task in theory, however, I have spent all day today and a significant chunk of yesterday trying to get this to work without much success.
I have tried posting the image as a Curl object as is necessary in other areas of the Facebook API, and it appears to be trying giving me an error that the image is generating a 404 error (it isn't, when I checked the access logs, it was never requested).
Please be someone out there who has had some success with this.
This has now been fixed by Facebook

LinkedIn PHP api issues

Today, after we migrated to the new members permissions api, everything goes wrong.
Im using the cosumer key and secret that i've got from the linkedin api dashboard itself with the oauth token and secret as well.
There is 3 kind of problems that keeps on coming:
first one:
{"errorCode": 0,"message": "Could not find person based on: ~","requestId": "7GPT96SW3C","status": 404,"timestamp": 1369827647671}
second:
<error><status>401</status><timestamp>1369826490661</timestamp><request-id>ZYWPUD43G3</request-id><error-code>0</error-code><message>[unauthorized]. The token used in the OAuth request is not valid. ******</message></error>
third:
com.linkedin.anet.auth.pub.ANetAuthException: other: anetID=*****
has anyone got some of these too? if yes, so how did you solved them?
thanks!
Once you have authenticated the user, you no longer need to make the access token calls - simply store the access token and reuse that for the subsequent requests.
Check are you sending a request once or twice for authentication, there may be the case your token getting replaced by another request.
I've gotten the "401<" and fixed it by correcting the URL which I was formatting incorrectly and consequently requesting a resource that did not exists (reported as unauthorized). You probably have the same issue with your 404 error. Can you please post the specific URLs you are using. That would give a little more insight. Also, make sure that you are not passing params via GET when you should be passing them via POST and that all your POST requests are via HTTPS

Cannot delete application invite in Facebook after acceptance

I've looked through this site and looked at the Facebook docs but I can't seem to delete an invite after a friend accepts.
So, what happens is:
1. Steve invites John to a game.
2. John receives that invite and clicks accept.
3. John is taken to the game, but the invite message is not delete in his facebook page.
Facebook docs suggests I add "method=delete" when I post to https://graph.facebook.com/[request_id]?access_token=xxxx
But that returns me "{"error":{"type":"OAuthException","message":"(#2) Invalid parameter: Unknown error"}}". I'm pretty sure I'm using the most recent access_token.
Can anyone provide me with sample code which deletes an application invite after a user accepts?
EDIT:
I also tried DELETE i.e. DELETE https://graph.facebook.com/[request_id]?access_token=xxxx
And I get the same error
Thanks.
There's brief examples at https://developers.facebook.com/docs/reference/dialogs/requests/ and a longer example on https://developers.facebook.com/blog/post/464/ which show how to do this.
It sounds from your comments on fjsj's answer that you know what you're supposed to be doing - it definitely looks OK to me.
It could be that you're encountering a bug of some kind, but I think in this case it's more likely that somehow the access token of the user is being sent or there's a slight error in the way you're accessing the API - If there's a specific error message you're getting back? maybe post that here if there is.
Two things to check:
Is the request you're trying to delete returned when you make a GET request to /<request id>? (using the app access token)
Are the requests being sent using the newer Requests 2.0 dialogs? If you're using the older requests system, the instructions are basically the same, but the connection you access the requests at is the [currently undocumented] /<USER>/platformrequests endpoint (as opposed to /<USER>/apprequests
Try doing a HTTP DELETE instead of a POST. This is what the documentation says.

Categories