If all the users are on single domain you can use Service Accounts.
Service account belongs to your application instead of to an
individual end user. Your application calls Google APIs on behalf of
the service account, so users aren't directly involved.
If users are not on the same domain, you will need to store
credentials for each user in your application. Here is the link which
helps you.

Here is one idea using dplyr and tidyr. I wrote a custom function
using your calculation information above. foo is your data. The last
digits for average lat do not exactly match with your expected
outcome. This may be possibly due to rounding.
library(dplyr)
library(tidyr)
test <- filter(foo, Stops != 0) %>% # drop rows with Stop == 0
unite(dates, BS, TS, sep = " ") %>% #creat