Skip to content

Instantly share code, notes, and snippets.

@almet
Last active January 18, 2016 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save almet/82d730ce73ccc12e8d8d to your computer and use it in GitHub Desktop.
Save almet/82d730ce73ccc12e8d8d to your computer and use it in GitHub Desktop.
diff --git a/calendar.js b/calendar.js
index ce462d6..faca709 100644
--- a/calendar.js
+++ b/calendar.js
@@ -10,17 +10,29 @@ $(document).ready(function() {
// Local store in IndexedDB.
var store;
-
var headers;
// Authentication from location hash
authenticate(window.location.hash.slice(1))
+ .then(function(authInfo) {
+ // Only do it if it's a FxA !
+
+ // We need to get the location of the user's server.
+ // 1. Create a new kinto instance, with the correct parameters.
+ // (remote: https://kinto.dev.mozaws.net/v1) -- central repository.
+ // 2. Do the request on the central repository to know if a server
+ // was configured for this user.
+
+ // When you have the correct URL, you pass it in authInfo.storageServer.
+ return authInfo;
+ })
.then(function (authInfo) {
+ console.log("Authentication Information", authInfo);
window.location.hash = authInfo.token;
headers = authInfo.headers;
// Kinto client with sync options.
- var kinto = new Kinto({remote: storageServer,
+ var kinto = new Kinto({remote: authInfo.storageServer,
bucket: bucket_id,
headers: headers,
dbPrefix: authInfo.username});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment