Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Added ability to extend tokens #24

Merged
merged 2 commits into from Aug 7, 2012

Conversation

mattwkelly
Copy link
Contributor

This adds the ability to get extended tokens. Most folks use the JS client-side flow to auth users, which generates a short-lived token.

They can now call extendAccessToken() in order to get an long-lived token.

Note that this also destroys the original JS session, so some discussion may be needed as I don't know of any unintended consequences this could have.

@mattwkelly
Copy link
Contributor Author

CC @scottmac @NShah

@mattwkelly
Copy link
Contributor Author

@scottmac Not sure what you mean. The JS SDK should be able to support getting long-lived tokens, but the PHP SDK should also support that.

@daaku
Copy link
Contributor

daaku commented Jun 12, 2012

This looks fine -- could you fix up the indentation/style and 80 col issues.


$this->destroySession();

$this->setPersistentData('access_token', $response_params['access_token']);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this method return the extended token value? after all is called getExtendedAccessToken, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@onema: I'll change the function name to set*. Sound reasonable?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually get* is not a bad name, just return the extended token you just requested for. set* is not a very good name because you are not setting anything (not passing any parameters, see other setter methods).

If you really don't want to return the token I think request* would be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is setting a new access token.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I posted this in January on StackOverflow, called it getExtendedAccessToken which seemed to make the most sense to me back then. I found most use in it when it returns the new accesstoken.

You can see it here, http://stackoverflow.com/questions/8982025/how-to-extend-access-token-validity-since-offline-access-deprecation/9035036#9035036

I'm also not sure why you'd want to destroy the session in there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoinScribbly, if you don't destroy the session, you'll end up with two, which can lead to all sorts of problems.

@mattwkelly
Copy link
Contributor Author

Updated. @NShah, @scottmac, good to go?

return false;
}

$this->destroySession();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you be destroying the session here? The only methods that use this in the BaseFacebook class are _rest and throwAPIException. this can cause problems if you don't leave it up to the user of the class to kill the session. Makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problems can it lead to?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a benefit in destroying the session here?

mattwkelly added a commit that referenced this pull request Aug 7, 2012
Added ability to extend tokens
@mattwkelly mattwkelly merged commit 1270f0d into facebookarchive:master Aug 7, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
7 participants