Hi,

a get this:

Access Token cannot be longer than 128 characters but is currently 192 characters long.

Do I get a shorter token by using less permissions?

Is there a way to overcome this issue?

Comments

Dave Cohen’s picture

I though I fixed a bug where the expires... was appended to the token. Look at the entire token and see if "&expires" is at the end. If so cut that part off.

phosgen’s picture

Priority: Normal » Major

Same issue over here..I cant copy the whole token generated by FB therefore getting an error message when trying to save the token-page.

Unable to query graph with fb_stream token.: fb_graph failed querying me. OAuthException: The access token could not be decrypted
There was an error using the current access token, 

When manipulating the inputfield so that more than 128 signs are allowed it get an error, that there are 222 instead of 128 signs. The token looks just the way it should with no "&expires" whatsoever at the end.

Dave Cohen’s picture

Status: Active » Needs review
StatusFileSize
new2.87 KB
new2.68 KB

I guess the tokens have grown longer because I hadn't seen the 128 character limit.

Please confirm this patch fixes. Attaching patches for Drupal 6.x and 7.x. Also fixed a bug in the longer-lived tokens.

Dave Cohen’s picture

StatusFileSize
new668 bytes

If using D7 apply this patch in addition to the ...d7 one above.

phosgen’s picture

THX for the fast response but is there a way of applying this patch without git?

Bogd@n’s picture

Hello,

I've have the same problem and concidered to apply the patches manually. The file to be patched is sites\all\modules\fb\fb_stream.admin.inc

I tried to locate the lines to be removed but I cannot find any of the code.

1.) Which file should be patched?
2.) Generic question, why patch part of file if you could copy & paste an entire file?

Thanks,
Bogdan

p.s. suggestions to patch a file on windows are welcome

Dave Cohen’s picture

Not sure about windows. I use a program called "patch" in linux.

phosgen’s picture

Thats just what I tried. But I wasn't able to locate the lines to be deleted too. Especially because there are 2 patches (when usnig D7) that have to merged into one file.

Here is what the community helpfile says about installing a patch.

Maybe an update will be supplied soon or maybe just an updated version of the 'fb_stream.admin.inc' file where all the changes have to take place.

-------------------------
update 23.04.13 . 20.00

What version of the Module did you write this patch for? The lines to be removed cant be found in the file mentioned ('fb_stream.admin.inc'). So it cant be applied using git either because the patch doesnt match the beta6 version at the moment.

Dave Cohen’s picture

Status: Needs review » Fixed

OK, pushed the changes. Use the .dev build to test.

Let me know if it's not fixed.

Bogd@n’s picture

hi,
expected an updated version, the latest .dev build is from 22-Mar !?

7.x-3.x-dev tar.gz (143.3 KB) | zip (178.65 KB) 2013-Mar-22 Notes

phosgen’s picture

Status: Fixed » Needs review

Hey Dave,

dev Version seems to work as far as inserting and saving n´the new token. But after saving I get the following error:

Notice: Undefined index: name in fb_stream_admin_settings() (Line 23 in /mnt/webi/e2/78/5139878/htdocs/drupal/sites/all/modules/fb/fb_stream.admin.inc).

--------------------------
update

Notice: Undefined index: name in fb_stream_form_alter() (Line 150 in /mnt/webi/e2/78/5139878/htdocs/drupal/sites/all/modules/fb/fb_stream.module).
Notice: Undefined index: name in fb_stream_post_options() (Line 231 in /mnt/webi/e2/78/5139878/htdocs/drupal/sites/all/modules/fb/fb_stream.module).
Notice: Undefined index: name in fb_stream_post_options() (Line 234 in /mnt/webi/e2/78/5139878/htdocs/drupal/sites/all/modules/fb/fb_stream.module).

I can save the token but still can't post to stream or anything else.

Dave Cohen’s picture

Status: Needs review » Active

If you're not getting a 'name' back from facebook, I wonder what you are getting. Can you add something like

dpm($from, __FUNCTION__);

right after $from = fb_graph('me', array('access_token' => $token)); (line 21 of fb_stream.admin.inc)?

(note for dpm() you need devel.module enabled.)

Reproduce the first notice by going to the settings form and let me know what it shows.

shivachevva’s picture

Iam using 7.x-3.3-beta6 version. The #3 patch didn't worked for me. So i just added '#maxlength' => 255
right after '#required' => TRUE, (line 52 of fb_stream.admin.inc) and worked for me.

phosgen’s picture

Status: Active » Needs review

Okay this seems to be not just an issue of the module alone (thx to shivachevva- fixed worked so far) but of the setup.
What I wanted is just a way to post on one FB-profile stream from this drupal site. Since the readme just wanted an app for fb-connect and canvas apps i didn't set one up. So the reason that there's no name coming back is..theres no app but the open graphi api explorer itself yet.

So I guess I have to set up an app first with my developer account..connect this app (somehow) with the customer FB-profile and then generate the access token from within that profile to use it in the module right?

Bogd@n’s picture

Status: Needs review » Active

I've installed "7.x-3.x-dev" and whohoo everything is working. The articles appear on facebook.
Thx,
Bogdan

p.s. drupal shows me two warnings something to worry about later.

Warning: strpos() expects parameter 1 to be string, array given in text_summary() (line 356 of /home/vreulsb1/domains/ventoux.nu/public_html/happylife/modules/field/modules/text/text.module).
Warning: substr() expects parameter 1 to be string, array given in text_summary() (line 365 of /home/vreulsb1/domains/ventoux.nu/public_html/happylife/modules/field/modules/text/text.module).

Dave Cohen’s picture

Status: Active » Fixed

@phosgen, You should not need fb_connect.module or fb_canvas.module if all you want to do is post to facebook. And you don't need drupal to host your app, you just need the right access token.

Since it sounds like phosgen and shicachewa did not apply the patch, I'm assuming this particular issue is fixed in .dev build.

phosgen’s picture

Status: Fixed » Needs review

As far as your patch goes it wasnt able to get it to work but the workaround from shivachevva in post #13 worked fine as far as the tokenlength goes.

Unfortunately the problem of being able to post to the stream still exists but seems to be a little more difficult.
When using my developer profile generating an access token everything is fine and works as expected. But I dont want to post messages to my developer profile. I want an customer site to post to the customers FB-account.

The problem ist, that the customer account is not a regular user account but a profile for bussinesses (dont know the exact name but thats the reason why the module is not getting a 'name' back from facebook). I cant use the dpm module with devel because alll I get is errors. But using the debugger on FB it doesn't seem like there is a 'name' argument being passed from FB("field ist empty or disallowed by the access token" with all permissions possible set).
The only available values are:

{
  "id": "", 
  "link": "", 
  "birthday": "", 
  "email": "", 
  "timezone": , 
  "locale": "", 
  "verified": , 
  "updated_time": ""
}

There is no option where I could enter a name (first name - last name = name) unlike in my developer profile.

So I guess its not a problem with the module, even tho I still dont know how to get it to work with a company profile. But maybe you can add a hint for users that this is just for personal user accounts.

FB Info:
Facebook removes offline access

THX for your help!

Dave Cohen’s picture

Status: Needs review » Fixed

Please open a separate issue to track that.

Wouldn't surprise me if a lot of code assumes a 'name' because I haven't ever seen a graph item without one. If you want to send me a token that exhibits this problem, that might help. I suppose a reasonable fallback is to use 'id' when 'name' is not found, if you feel like submitting a patch.

zet’s picture

http://drupal.org/node/1128892

(-p1 patches are now required, and -p0 patches are phased out on Drupal.org)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rudy.barrett’s picture

StatusFileSize
new498 bytes

I installed the latest dev module but I still could not enter the full Facebook Token, it was too long for the field in stream_admin and our website could not post to Facebook. I have created a patch to increase the maxlength of the fb_stream_admin_settings field in fb_stream.admin.inc to 305 characters and I was able to enter the full token.

Hope this helps someone else!

Dave Cohen’s picture

Version: 7.x-3.3-beta6 » 7.x-3.x-dev
Status: Closed (fixed) » Active

This makes me think access tokens need to be in text areas and not just text fields.

sigh.

elijah lynn’s picture

StatusFileSize
new673 bytes

For those using the latest beta (7.x-3.3-beta6) here is a simple patch you can apply to get this working.

#22 Dave - Yeah, it would be good to just make it a text area given the docs you linked to. If anyone wants to convert the token from textfield to textarea on dev then it would be appreciated!

Update: Ignore this patch for now, it doesn't fully work, I am working on getting it all working and will update it when it is.
Update 2: I moved to the latest dev. Don't apply this patch, it won't help you.

elijah lynn’s picture

Status: Active » Needs review
StatusFileSize
new3.21 KB

Per #22

Here is a patch to make the textfield a textarea though. Look at the third diff block. The rest are just comment cleanup. I can submit that separate if you want.

This is just one form, not sure where else it may be required.

Dave Cohen’s picture

Status: Needs review » Fixed

Just pushed change to use textarea in both 6.x and 7.x.

elijah lynn’s picture

Nice, much easier to read the token now too.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

gmaximus’s picture

comment #21 done it for me... although i'm using the D6 stable release and had to add " '#maxlength' => 305," myself as the max length wasn't originally defined in that copy... I added it in the same place as his patch said though... Thought it was worth a mention for anyone else scratching their heads wondering what's going on...

very surprised that the stable version doesn't actually work, in terms of posting content to a page on fb... Hey ho! didn't find too long to find this i guess...