Right, so I've just spent a few hours on this and the good news is I got the Python sample to work and think I now have my head wrapped around oauth enough in terms of all the challenge/response tokens/secrets etc. I also don't anticipate any issues with including all of this in a plugin.
Here is the basic sequence that will take place for anyone interested:
- I've applied for and received a token/secret key for a Calibre GoodReads plugin application. This will be hard-coded into the plugin.
- Each user will need to authorize the plugin with their GoodReads account. This is a one-off exercise.
- To do this, they will need to go into the configuration dialog for the plugin where I will have a button saying something like "Authorize plugin with GoodReads".
- When you click this button, it will launch a web-browser at a page asking you to log into GoodReads (if you are not already), and then click on a button on their website to authorize the plugin.
- You will then need to switch back to Calibre, which will have opened a question dialog waiting for you to tell it that you have authorized in GoodReads. Kind of like saying "yes twice" but necessary as we are not using a callback website to tell us that the user has finished authorizing on the GoodReads site
- At this point I can retrieve a token/secret combination for that user which I will store in a configuration file for the plugin on the user's PC.
- Now with that token/secret in combination with the dev token/secret I am able to make API calls to either retrieve or send information to GoodReads.
- If you go into the GoodReads website and click on "Account" there is a tab called "Apps" which you will then see the Calibre GoodReads plugin listed as. You can "deauthorize" it from there if you wanted to for some reason. Of course to use again from Calibre you would need to go back through the above steps again, as the token stored with Calibre will no longer be valid.
So all pretty simple really in the end...
In terms of the UI for the plugin. I'm going to describe below what I have in mind, if anyone has objections/changes let me know asap.
- Authorization via the configuration dialog as described above
- Adding books to a shelf came up as the #1 requirement. I am guessing you would like to be able to pick a shelf to add books to, such as via a submenu in the context menu: e.g.
Add books to shelf ->
- Rather than reading the shelves list each time Calibre starts the plugin, it will be modified via the configuration dialog. A "Refresh shelves" button will populate a list from which you can select which are to appear in the menu. If you add/remove shelves using the GoodReads website (a presumably rare occurrence), you will go back into the plugin configuration dialog to refresh the list again.
- I will also add a "Remove books from Shelf" menu option, to allow you to undo an "Add" action from Calibre without having to go to the GoodReads website.
Any comments or ideas for other functionality you would like to see? The full list of the API is listed here
. I have some ideas but as I'm not a hardcore GoodReads user I'm more interested in what others are wishing for.