Skip to content

Conversation

@jmoldow
Copy link
Contributor

@jmoldow jmoldow commented Sep 22, 2016

Rename JWTAuth.authenticate_app_user() to
JWTAuth.authenticate_user(), to reflect the fact that the new
Box service accounts can authenticate as managed users as well
as app users. JWTAuth.authenticate_app_user() is retained as
an alias, for backwards-compatability.

Allow a user ID to be passed to JWTAuth, instead of a User
object. Previously, developers would need to import and manually
construct a boxsdk.object.user.User, since Client.user()
cannot be used until the Client has been constructed (which is
usually done after all authentication is complete).

Allow a user or user ID to be passed to the JWTAuth
constructor. This way, JWTAuth.authenticate_user() can be
called without any arguments. More importantly, this means that
JWTAuth.refresh() can be called immediately after
construction, with no need for a manual call to
JWTAuth.authenticate_user().

When auto_session_renewal=True, if there is no access token,
then BoxSession.request() will renew the token before making
the request. This saves an API call. And combined with the
above, authentication for JWTAuth objects can be done
completely automatically, at the time of first API call.

Document that the enterprise_id argument to JWTAuth is
allowed to be None (and must be None if user is passed).
Also allow it to be passed to authenticate_instance(), so that
it doesn't need to be provided at construction time.

Clean up the README.

Fixes #174.

@boxcla
Copy link

boxcla commented Sep 22, 2016

Verified that @jmoldow has signed the CLA. Thanks for the pull request!

Rename `JWTAuth.authenticate_app_user()` to
`JWTAuth.authenticate_user()`, to reflect the fact that the new
Box service accounts can authenticate as managed users as well
as app users. `JWTAuth.authenticate_app_user()` is retained as
an alias, for backwards-compatability.

Allow a user ID to be passed to `JWTAuth`, instead of a `User`
object. Previously, developers would need to import and manually
construct a `boxsdk.object.user.User`, since `Client.user()`
cannot be used until the `Client` has been constructed (which is
usually done after all authentication is complete).

Allow a user or user ID to be passed to the `JWTAuth`
constructor. This way, `JWTAuth.authenticate_user()` can be
called without any arguments. More importantly, this means that
`JWTAuth.refresh()` can be called immediately after
construction, with no need for a manual call to
`JWTAuth.authenticate_user()`.

When `auto_session_renewal=True`, if there is no access token,
then `BoxSession.request()` will renew the token _before_ making
the request. This saves an API call. And combined with the
above, authentication for `JWTAuth` objects can be done
completely automatically, at the time of first API call.

Document that the `enterprise_id` argument to `JWTAuth` is
allowed to be `None` (and must be `None` if `user` is passed).
Also allow it to be passed to `authenticate_instance()`, so that
it doesn't need to be provided at construction time.

Clean up the README.

Fixes #174.
The initial commit that added the `user` parameter to `JWTAuth`
only allowed it to be passed when `enterprise_id=None` was
passed.

After playing around with this a little bit, I determined that
this is unnecessarily inflexible for developers. So this
constraint is now relaxed. They can both be passed, with `user`
taking precedence.

Fixup for Pull Request #178.
@Jeff-Meadows
Copy link
Contributor

👍

@jmoldow jmoldow merged commit 61f54c6 into master Nov 10, 2016
@jmoldow jmoldow deleted the jwt_user branch November 10, 2016 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants