Good morning,
I have a long running process that starts by reading the directory contents of between 70k + 700k files, when running the process on a very small set of data, it works 100%, on my side of the process it then runs a series of ‘things’ on that data, then generates a metadata template and stamps it on the file. This works 100% until, what I think is, the token becoming stale/invalid/expired. I say this because if this process runs for like 4-6hrs, nothing. It works perfect, but around 24hr, when i stamp the template i get 401 errors.
So the first thing i did (my program is in Rust) is re-build my auth before stamping the templates.
Example Code:
let client = Client::builder().build().unwrap();
let params = s
(“client_id”, “”),
(“client_secret”, “”),
(“grant_type”, “client_credentials”),
(“box_subject_type”, “enterprise”),
(“box_subject_id”, “534608”),
];
//Get client token
let response = client
.post(“https://api.box.com/oauth2/token”)
.form(¶ms)
.send()
.await
.unwrap();
let t = response.json::().await.unwrap();
Then what happens is i have a client object and when i go to write, I grab the client and insert the token:
let response = &self
.client
.post(&url)
.bearer_auth(&self.token.access_token)
.header(header::CONTENT_TYPE, “application/json”)
.body(final_body.clone())
.send()
.await
.unwrap();
So what I did is, basically call this code again:
let response = client
.post(“https://api.box.com/oauth2/token”)
.form(¶ms)
.send()
.await
.unwrap();
let t = response.json::().await.unwrap();
which returns a token the same as when i started (which works of course to read the folders and files) and then try to write the templates…
I get 401 errors.
sWriting template to file: 1553933437399 …Template for file: 1553933437399 Error: 401 IsInformational ?: false IsClientError? : true]
When i look at documenation for Templates there is no listed 401 error:
Even weirder is, 3 weeks ago I ran this program AS IS, on a 220k folder and it ran to completion, this entire 401 issue only started in last 2 weeks (ish) range, did something change?
So I guess my questions are:
- With Client Credentials Grant how long is the token valid for.
- Why re-authing does the template stamp not work, while all the other API calls do.
- Why did this sudden start/change? What has changed to this process?
Please any help would be great as my project deadline is very close and this ‘was working’
Thank you,
Andrew