You can buy and sell Bitcoin with a US bank account directly in Copay.
Connect your Glidera account to get started
-
diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js
index 0b8d6d6ed..40902df89 100644
--- a/src/js/controllers/glidera.js
+++ b/src/js/controllers/glidera.js
@@ -4,14 +4,17 @@ angular.module('copayApp.controllers').controller('glideraController',
function($scope, $timeout, $modal, applicationService, profileService, configService, storageService, glideraService) {
var config = configService.getSync().wallet.settings;
- this.authenticateUrl = glideraService.getOauthCodeUrl();
- this.submitOauthCode = function(code) {
+ this.getAuthenticateUrl = function() {
+ return glideraService.getOauthCodeUrl();
+ };
+
+ this.submitOauthCode = function(code, glideraCredentials) {
var fc = profileService.focusedClient;
var self = this;
this.loading = true;
$timeout(function() {
- glideraService.getToken(code, function(error, data) {
+ glideraService.getToken(code, glideraCredentials, function(error, data) {
if (data && data.access_token) {
storageService.setGlideraToken(fc.credentials.network, data.access_token, function() {
$scope.$emit('Local/GlideraTokenUpdated', data.access_token);
diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js
index be636889f..8704c9456 100644
--- a/src/js/controllers/index.js
+++ b/src/js/controllers/index.js
@@ -113,6 +113,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.pendingTxProposalsCountForUs = null;
self.setSpendUnconfirmed();
+ self.glideraCredentials = null;
self.glideraToken = null;
self.glideraError = null;
self.glideraPermissions = null;
@@ -839,6 +840,7 @@ console.log('[index.js:395]',txps); //TODO
self.initGlidera = function(accessToken) {
if (self.isShared) return;
+ self.glideraCredentials = glideraService.init(self.network);
var getToken = function(cb) {
if (accessToken) {
@@ -852,7 +854,6 @@ console.log('[index.js:395]',txps); //TODO
if (err || !accessToken) return;
else {
self.glideraLoading = gettext('Connecting to Glidera...');
- glideraService.init(self.network);
glideraService.getAccessTokenPermissions(accessToken, function(err, p) {
self.glideraLoading = null;
if (err) {
diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js
index 1932f8735..05ba9fbc7 100644
--- a/src/js/services/glideraService.js
+++ b/src/js/services/glideraService.js
@@ -2,39 +2,36 @@
angular.module('copayApp.services').factory('glideraService', function($http, $log) {
var root = {};
-
- var HOST;
- var REDIRECT_URI;
- var CLIENT_ID;
- var CLIENT_SECRET;
+ var credentials = {};
root.init = function(network) {
if (network == 'testnet') {
- HOST = 'https://sandbox.glidera.io';
- REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
- CLIENT_ID = '9915b6ffa6dc3baffb87135ed3873d49';
- CLIENT_SECRET = 'd74eda05b9c6a228fd5c85cfbd0eb7eb';
+ credentials.HOST = 'https://sandbox.glidera.io';
+ credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
+ credentials.CLIENT_ID = '9915b6ffa6dc3baffb87135ed3873d49';
+ credentials.CLIENT_SECRET = 'd74eda05b9c6a228fd5c85cfbd0eb7eb';
}
else {
- HOST = 'https://glidera.io';
- REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
- CLIENT_ID = '';
- CLIENT_SECRET = '';
- }
+ credentials.HOST = 'https://glidera.io';
+ credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
+ credentials.CLIENT_ID = '';
+ credentials.CLIENT_SECRET = '';
+ };
+ return credentials;
};
root.getOauthCodeUrl = function() {
- return HOST
+ return credentials.HOST
+ '/oauth2/auth?response_type=code&client_id='
- + CLIENT_ID
+ + credentials.CLIENT_ID
+ '&redirect_uri='
- + REDIRECT_URI;
+ + credentials.REDIRECT_URI;
};
root.getToken = function(code, cb) {
var req = {
method: 'POST',
- url: HOST + '/api/v1/oauth/token',
+ url: credentials.HOST + '/api/v1/oauth/token',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
@@ -42,9 +39,9 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
data: {
grant_type : 'authorization_code',
code: code,
- client_id : CLIENT_ID,
- client_secret: CLIENT_SECRET,
- redirect_uri: REDIRECT_URI
+ client_id : credentials.CLIENT_ID,
+ client_secret: credentials.CLIENT_SECRET,
+ redirect_uri: credentials.REDIRECT_URI
}
};
@@ -60,7 +57,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
var _get = function(endpoint, token) {
return {
method: 'GET',
- url: HOST + '/api/v1' + endpoint,
+ url: credentials.HOST + '/api/v1' + endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
@@ -172,7 +169,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
var _post = function(endpoint, token, twoFaCode, data) {
return {
method: 'POST',
- url: HOST + '/api/v1' + endpoint,
+ url: credentials.HOST + '/api/v1' + endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',