Fixes oath code url for livenet/testnet
This commit is contained in:
parent
71471f2aad
commit
e9b74fcddc
4 changed files with 32 additions and 30 deletions
|
|
@ -26,14 +26,15 @@
|
||||||
<img src="img/glidera-logo.png">
|
<img src="img/glidera-logo.png">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="!index.glideraToken && !index.glideraLoading && !index.glideraError" class="row">
|
<div ng-if="index.glideraCredentials && !index.glideraToken && !index.glideraLoading && !index.glideraError"
|
||||||
|
class="row">
|
||||||
<div class="columns" ng-init="showOauthForm = false">
|
<div class="columns" ng-init="showOauthForm = false">
|
||||||
<div class="text-center" ng-show="!showOauthForm">
|
<div class="text-center" ng-show="!showOauthForm">
|
||||||
<p translate>You can buy and sell Bitcoin with a US bank account directly in Copay.</p>
|
<p translate>You can buy and sell Bitcoin with a US bank account directly in Copay.</p>
|
||||||
<div class="m10b text-gray size-12" translate>Connect your Glidera account to get started</div>
|
<div class="m10b text-gray size-12" translate>Connect your Glidera account to get started</div>
|
||||||
<button
|
<button
|
||||||
class="dark-gray outline round tiny"
|
class="dark-gray outline round tiny"
|
||||||
ng-click="$root.openExternalLink(glidera.authenticateUrl); showOauthForm = true" translate>
|
ng-click="$root.openExternalLink(glidera.getAuthenticateUrl()); showOauthForm = true" translate>
|
||||||
Connect to Glidera
|
Connect to Glidera
|
||||||
</button>
|
</button>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,17 @@ angular.module('copayApp.controllers').controller('glideraController',
|
||||||
function($scope, $timeout, $modal, applicationService, profileService, configService, storageService, glideraService) {
|
function($scope, $timeout, $modal, applicationService, profileService, configService, storageService, glideraService) {
|
||||||
|
|
||||||
var config = configService.getSync().wallet.settings;
|
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 fc = profileService.focusedClient;
|
||||||
var self = this;
|
var self = this;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
glideraService.getToken(code, function(error, data) {
|
glideraService.getToken(code, glideraCredentials, function(error, data) {
|
||||||
if (data && data.access_token) {
|
if (data && data.access_token) {
|
||||||
storageService.setGlideraToken(fc.credentials.network, data.access_token, function() {
|
storageService.setGlideraToken(fc.credentials.network, data.access_token, function() {
|
||||||
$scope.$emit('Local/GlideraTokenUpdated', data.access_token);
|
$scope.$emit('Local/GlideraTokenUpdated', data.access_token);
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.pendingTxProposalsCountForUs = null;
|
self.pendingTxProposalsCountForUs = null;
|
||||||
self.setSpendUnconfirmed();
|
self.setSpendUnconfirmed();
|
||||||
|
|
||||||
|
self.glideraCredentials = null;
|
||||||
self.glideraToken = null;
|
self.glideraToken = null;
|
||||||
self.glideraError = null;
|
self.glideraError = null;
|
||||||
self.glideraPermissions = null;
|
self.glideraPermissions = null;
|
||||||
|
|
@ -839,6 +840,7 @@ console.log('[index.js:395]',txps); //TODO
|
||||||
|
|
||||||
self.initGlidera = function(accessToken) {
|
self.initGlidera = function(accessToken) {
|
||||||
if (self.isShared) return;
|
if (self.isShared) return;
|
||||||
|
self.glideraCredentials = glideraService.init(self.network);
|
||||||
|
|
||||||
var getToken = function(cb) {
|
var getToken = function(cb) {
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
|
|
@ -852,7 +854,6 @@ console.log('[index.js:395]',txps); //TODO
|
||||||
if (err || !accessToken) return;
|
if (err || !accessToken) return;
|
||||||
else {
|
else {
|
||||||
self.glideraLoading = gettext('Connecting to Glidera...');
|
self.glideraLoading = gettext('Connecting to Glidera...');
|
||||||
glideraService.init(self.network);
|
|
||||||
glideraService.getAccessTokenPermissions(accessToken, function(err, p) {
|
glideraService.getAccessTokenPermissions(accessToken, function(err, p) {
|
||||||
self.glideraLoading = null;
|
self.glideraLoading = null;
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -2,39 +2,36 @@
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('glideraService', function($http, $log) {
|
angular.module('copayApp.services').factory('glideraService', function($http, $log) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
var credentials = {};
|
||||||
var HOST;
|
|
||||||
var REDIRECT_URI;
|
|
||||||
var CLIENT_ID;
|
|
||||||
var CLIENT_SECRET;
|
|
||||||
|
|
||||||
root.init = function(network) {
|
root.init = function(network) {
|
||||||
if (network == 'testnet') {
|
if (network == 'testnet') {
|
||||||
HOST = 'https://sandbox.glidera.io';
|
credentials.HOST = 'https://sandbox.glidera.io';
|
||||||
REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
||||||
CLIENT_ID = '9915b6ffa6dc3baffb87135ed3873d49';
|
credentials.CLIENT_ID = '9915b6ffa6dc3baffb87135ed3873d49';
|
||||||
CLIENT_SECRET = 'd74eda05b9c6a228fd5c85cfbd0eb7eb';
|
credentials.CLIENT_SECRET = 'd74eda05b9c6a228fd5c85cfbd0eb7eb';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HOST = 'https://glidera.io';
|
credentials.HOST = 'https://glidera.io';
|
||||||
REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
||||||
CLIENT_ID = '';
|
credentials.CLIENT_ID = '';
|
||||||
CLIENT_SECRET = '';
|
credentials.CLIENT_SECRET = '';
|
||||||
}
|
};
|
||||||
|
return credentials;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getOauthCodeUrl = function() {
|
root.getOauthCodeUrl = function() {
|
||||||
return HOST
|
return credentials.HOST
|
||||||
+ '/oauth2/auth?response_type=code&client_id='
|
+ '/oauth2/auth?response_type=code&client_id='
|
||||||
+ CLIENT_ID
|
+ credentials.CLIENT_ID
|
||||||
+ '&redirect_uri='
|
+ '&redirect_uri='
|
||||||
+ REDIRECT_URI;
|
+ credentials.REDIRECT_URI;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getToken = function(code, cb) {
|
root.getToken = function(code, cb) {
|
||||||
var req = {
|
var req = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: HOST + '/api/v1/oauth/token',
|
url: credentials.HOST + '/api/v1/oauth/token',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
|
|
@ -42,9 +39,9 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
||||||
data: {
|
data: {
|
||||||
grant_type : 'authorization_code',
|
grant_type : 'authorization_code',
|
||||||
code: code,
|
code: code,
|
||||||
client_id : CLIENT_ID,
|
client_id : credentials.CLIENT_ID,
|
||||||
client_secret: CLIENT_SECRET,
|
client_secret: credentials.CLIENT_SECRET,
|
||||||
redirect_uri: REDIRECT_URI
|
redirect_uri: credentials.REDIRECT_URI
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -60,7 +57,7 @@ angular.module('copayApp.services').factory('glideraService', function($http, $l
|
||||||
var _get = function(endpoint, token) {
|
var _get = function(endpoint, token) {
|
||||||
return {
|
return {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: HOST + '/api/v1' + endpoint,
|
url: credentials.HOST + '/api/v1' + endpoint,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': '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) {
|
var _post = function(endpoint, token, twoFaCode, data) {
|
||||||
return {
|
return {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: HOST + '/api/v1' + endpoint,
|
url: credentials.HOST + '/api/v1' + endpoint,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue