evg4b / pb-dropbox-downloader

DropBox client for PocketBook reader written on Go.
https://pb-dropbox-downloader.netlify.app
MIT License
5 stars 1 forks source link

Application as product. #2

Open iMega opened 2 years ago

iMega commented 2 years ago

We need an app for the regular user. The application should have a simple and user-friendly interface for syncing files with Dropbox.

Main functions:

UX:

The user installs the application in PB and launches it. The first time application will show the qr-code. It helps the user to get authorized. The user goes to Dropbox and receives a code for the application. The user must types this code in the application. The application uses this code to get an access token and a refresh token. Further, the application works with Dropbox. The app should validate the configuration and token the next time the user launches the application. If the refresh token has expired, the user must authenticate again with the QR code.

Authorization via dropbox:

Optional:

My guess is that if we can use the exchange server's dropbox pin authentication code, it will be more user-friendly. Because the authorization code is very long. (https://dropbox.tech/developers/pkce--what-and-why-). We need a service that can give an authorization code using a pin code. This service must be available 24/7.

evg4b commented 2 years ago

Hey, that sounds really cool. I already have dropbox application. But I can't change the status to production now.

Production status removes the limits on the number of Dropbox users or teams your app can link. You may apply for production status at anytime, but your application will not be reviewed until your app has at least 50 Dropbox users (legacy Business API apps are not subject to this requirement). While your app has development status, it can link up to 500 Dropbox users or 5 Dropbox teams, so in most cases, it's safe to release your app to the world before it's been granted production status. Once your app links 50 users, you must apply for production within two weeks. If your app has not been granted production status at the end of two weeks, it won't be able to link any more users.

There is a site for authorization https://github.com/evg4b/pb-dropbox-downloader-site.

Authorization from the device can be complex because the SDK binding (user input and graphic printing) imposes many restrictions. For some of the functions, you need to make changes (add bindings) to the go inkview SDK.

Also, I'm not sure that I will have so much free time to implement all this in the nearest time. But if you'd like to submit pull requests, I'll gladly make all necessary changes to merge and improve the application.

iMega commented 2 years ago

Yes, I know about your Dropbox app.

I solved several problems:

evg4b commented 2 years ago

Would you like to share code examples?

iMega commented 2 years ago

There are several questions that need to be addressed:

evg4b commented 2 years ago

I would prefer to start with points 5 and 3. And make a stable version with correct communication with the dropbox server and new books detection.

In the next iteration make: self update (I've wanted to try selfupdate for a long time) and create and apply UI version and all the features you described.

But I don't agree with one point. I would not like to create a custom server for authorization. Since the application should work even when it is no longer supported. Perhaps a better option would be to do a workaround: make the ability for a user to enter data from the keyboard when the server is not available. I also had an idea to implement saving the configuration when connecting the book via file system API . I think this idea also deserves attention as an experiment.

What do you think?

iMega commented 1 year ago

I have created two versions. The first is when we use a pin code server. The pin server will exchange the pin for the dropbox code. The second is without a pin code, when you need to enter a long code from the dropbox (~ 40 characters). In any case, the first way is easier for the end user. This app config is very flexible https://github.com/iMega/pb-dropbox-downloader/blob/main/config/config.go#L36-L39. But we can know how the end user will use it. I assumed that the end user is a very lazy person and does not need to think about how it works. The end user only needs books.

1st task. I double checked a working app in the background. This works fine.

2nd task. Unfortunately my pocketbook 624 doesn't work properly when I use the NetConnect from SDK (https://github.com/iMega/pb-dropbox-downloader/blob/main/pbsdk/inkview.h#L1096). The first problem was that I was using a 12 MHz radio channel instead of 10 MHz. Haha. Secondly, the SDK does not return all the available networks that I used before. Maybe my PB is wrong.

3rd task. Could you tell me why you used it (https://github.com/evg4b/pb-dropbox-downloader/blob/main/go.mod#L8) please?

About your idea: If I understand correctly, you said about the config application. Now the application can download the configuration from the repository (https://github.com/iMega/pb-dropbox-downloader/blob/main/app/app.go#L84) and https://github.com/iMega/pb. -dropbox-downloader/blob/main/config/pb-dropbox-downloader.cfg. In this config, you must write a link to your repository. Note. And replace AppID. This must be done before publishing a new version of the application.

Short review:

  1. You install the app in PB to /applications and run it.
  2. The app will try to discover the network, otherwise the "Select Networks" dialog box will be displayed.
  3. The app loads the config from the disk, otherwise it downloads from the repo.
  4. It downloads translations from disk, otherwise downloads from repo.
  5. The application will try to detect the SD card and use it, otherwise it will use the main drive.
  6. If the access token is valid, it will sync the book library. if not, it will try to get a new access token via a refresh token.
  7. If the refresh token does not exist, the app will show a QR code with a URL to authenticate via Dropbox. Next, the end user enters a pin or code (I mentioned above) and receives a refresh token.
  8. The application again goes from the 6th point.
evg4b commented 1 year ago

My idea: To Implement first step of pkce authorization on site. Then write config and update application via file system api from browser (reader should be connected to pc). Config should contain dropbox api code and code verifier. First run: application requests access/refresh token pair, saves them in database and removes code and code verifier from configuration.

Currently I have draft of pkce implementation but I haven't had time to make changes in the application yet.

evg4b commented 1 year ago

go-billy is cool file system abstraction package. It allow very easy mock filesystem or provide isolated folder (used to debug application on pc).