Last active
July 24, 2023 08:37
-
-
Save sjb9774/5d70e7c56a33b1529cfa9fce1bccf101 to your computer and use it in GitHub Desktop.
Used with the Shopify Node App Template to get the access token stored in the installation session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run from within app web/ directory, presumes the sqlite db file is named "database.sqlite" (default for template) | |
const DB_FILE_PATH = './database.sqlite'; | |
const getAccessToken = async () => { | |
return new Promise((resolve, reject) => { | |
import('sqlite3').then((sqlite) => { | |
const db = new sqlite.default.Database(DB_FILE_PATH); | |
db.serialize(() => { | |
db.get('SELECT accessToken FROM shopify_sessions LIMIT 1;', [], (err, { accessToken }) => { | |
return resolve(accessToken); | |
}); | |
}); | |
}); | |
}); | |
} | |
console.log(await getAccessToken()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment