Skip to content

developers import

nhmkdev edited this page Sep 2, 2017 · 3 revisions

Developers - Import

CardMaker layouts are driven by data. Even if there is no reference associated at least one entry is created.

Import Types

As of this writing the Deck class triggers the request to load a reference.

Nothing (default if the others error)

This is easy! Deck.ProcessLines simply adds a single line. As of this writing the code for this is no seperated out like the other import types (and probably should be).

CSV

Using the CSVFile class lines are read from the file. There are some hacks to attempt to work around file locking that arises if the user operates with an editor that locks the CSV file.

Google Spreadsheets

Google spreadsheets are referenced using a special string that indicates the name of the spreadsheet and subsheet to pull data from.

OAUTH2

Google does not offer an OAUTH2 option that streamlines things like renewing tokens for previously authorized CardMaker users.

As of this writing the token timeout is 1 hour. After this the application must go through the authentication process again.

Authentication

Currently the model being followed is detailed here: https://developers.google.com/identity/protocols/OAuth2UserAgent

OAUTH2 tokens can be configured here: https://console.developers.google.com

Basically the steps are as follows:

  1. (in CardMaker) User is shown the Google Credentials prompt and selects Browse To URL
  2. This request hits a php page (cardmaker_oauth2_v2_request.php) on my site that forwards the browser to Google
  3. The user has to authorize CardMaker to access Google Spreadsheets (Google webpage)
  4. Google then forwards the browser to my site on a landing page (cardmaker_oauth2_v2_callback.php) that processes the navigation (and fragment data) and presents a token
  5. The token has to be copied back into CardMaker for use when accessing Spreadsheets

This is the best alternative to embedding the private key in the application (terrible idea, open source or not) OR running my own backend sql server to keep track of user tokens (also a terrible idea).

Import Extras

In addition to importing the main reference file each importer supports pulling in the project wide and layout specific define references.