DGoomani
DGoomani

Reputation: 71

Upload a file to my own box.net account from Javascript or PHP.

I have a box.net account and I want to be able to upload a file to my own account via a Javascript script I'm writing (which is collating data as JSON). I also wouldn't mind doing this via PHP by AJAXing the data to a PHP script.

The problem is I can't really work out how to do it, after some extensive searching. All I seem to find is ways to d via apps with user-based web authentication to get an auth token, but I don't want there to be any human interaction with my script.

Upvotes: 0

Views: 398

Answers (1)

MikeHunter
MikeHunter

Reputation: 4304

If you design your script right, no interaction will be necessary except the 1st time you run it and login through the oauth2 process. This will get you an access_token, a refresh_token, and the number of seconds before the access_token will expire (expires_in). Just serialize these 3 items (I convert expires_in to an absolute time) and retrieve when you run your script again. At that point, you can examine the expires_in value and decide how to proceed (with either access or refresh token). The refresher lasts 14 days, so if you wait that long before running your script again, then you'll have to log in again. But if you run at least once every 14 days, then you'll not have to login, theoretically ever, since you get a new refresher every time you refresh the access_token.

good luck,

Mike

Upvotes: 1

Related Questions