Merge pull request #12 from 30x/xapid-630
Xapid 630
diff --git a/apigee_sync.go b/apigee_sync.go
index 247253f..44845e6 100644
--- a/apigee_sync.go
+++ b/apigee_sync.go
@@ -13,23 +13,10 @@
"time"
)
-var token string = ""
+var token string
var downloadDataSnapshot, downloadBootSnapshot, changeFinished bool
var lastSequence string
-/*
- * NOTE: FIXME XAPID-629
- * The following function is just a temporary hack for analytics plugin to
- * consume this function to get the bearer token. In the future there will
- * have to be a common plugin, that shall provide such info.
- */
-type Export struct {
-}
-
-func (c Export) GetCurrentToken() string {
- return token
-}
-
func addHeaders(req *http.Request) {
req.Header.Add("Authorization", "Bearer "+token)
req.Header.Set("apid_instance_id", apidInfo.InstanceID)
@@ -279,6 +266,12 @@
return false
}
token = oauthResp.AccessToken
+
+ /*
+ * This stores the bearer token for any other plugin to
+ * consume.
+ */
+ config.Set(bearerToken, token)
log.Debug("Got a new Bearer token.")
return true
}
diff --git a/init.go b/init.go
index 7eda269..e78b399 100644
--- a/init.go
+++ b/init.go
@@ -20,7 +20,10 @@
ApigeeSyncEventSelector = "ApigeeSync"
// special value - set by ApigeeSync, not taken from configuration
- configApidInstanceID = "apigeesync_apid_instance_id"
+ configApidInstanceID = "apigeesync_apid_instance_id"
+ // This will not be needed once we have plugin
+ // handling tokens.
+ bearerToken = "apigeesync_bearer_token"
)
var (