@@ -26,7 +26,7 @@ var requiredKeys = [
2626 */
2727
2828function OAuthProvider ( ) {
29- var config ;
29+ var defaultConfig ;
3030
3131 /**
3232 * Configure.
@@ -36,7 +36,7 @@ function OAuthProvider() {
3636
3737 this . configure = function ( params ) {
3838 // Can only be configured once.
39- if ( config ) {
39+ if ( defaultConfig ) {
4040 throw new Error ( 'Already configured.' ) ;
4141 }
4242
@@ -46,31 +46,30 @@ function OAuthProvider() {
4646 }
4747
4848 // Extend default configuration.
49- config = angular . extend ( { } , defaults , params ) ;
49+ defaultConfig = angular . extend ( { } , defaults , params ) ;
5050
5151 // Check if all required keys are set.
5252 angular . forEach ( requiredKeys , ( key ) => {
53- if ( ! config [ key ] ) {
53+ if ( ! defaultConfig [ key ] ) {
5454 throw new Error ( `Missing parameter: ${ key } .` ) ;
5555 }
5656 } ) ;
5757
5858 // Remove `baseUrl` trailing slash.
59- if ( '/' === config . baseUrl . substr ( - 1 ) ) {
60- config . baseUrl = config . baseUrl . slice ( 0 , - 1 ) ;
59+ if ( '/' === defaultConfig . baseUrl . substr ( - 1 ) ) {
60+ defaultConfig . baseUrl = defaultConfig . baseUrl . slice ( 0 , - 1 ) ;
6161 }
6262
6363 // Add `grantPath` facing slash.
64- if ( '/' !== config . grantPath [ 0 ] ) {
65- config . grantPath = `/${ config . grantPath } ` ;
64+ if ( '/' !== defaultConfig . grantPath [ 0 ] ) {
65+ defaultConfig . grantPath = `/${ defaultConfig . grantPath } ` ;
6666 }
6767
6868 // Add `revokePath` facing slash.
69- if ( '/' !== config . revokePath [ 0 ] ) {
70- config . revokePath = `/${ config . revokePath } ` ;
69+ if ( '/' !== defaultConfig . revokePath [ 0 ] ) {
70+ defaultConfig . revokePath = `/${ defaultConfig . revokePath } ` ;
7171 }
72-
73- return config ;
72+ return defaultConfig ;
7473 } ;
7574
7675 /**
@@ -85,7 +84,7 @@ function OAuthProvider() {
8584 */
8685
8786 constructor ( ) {
88- if ( ! config ) {
87+ if ( ! defaultConfig ) {
8988 throw new Error ( '`OAuthProvider` must be configured first.' ) ;
9089 }
9190 }
@@ -110,7 +109,10 @@ function OAuthProvider() {
110109 * @return {promise } A response promise.
111110 */
112111
113- getAccessToken ( data , options ) {
112+ getAccessToken ( data , options , config ) {
113+ //Override default Oauth config
114+ config = angular . extend ( { } , defaultConfig , config ) ;
115+
114116 data = angular . extend ( {
115117 client_id : config . clientId ,
116118 grant_type : 'password'
@@ -145,7 +147,10 @@ function OAuthProvider() {
145147 * @return {promise } A response promise.
146148 */
147149
148- getRefreshToken ( data , options ) {
150+ getRefreshToken ( data , options , config ) {
151+ //Override default Oauth config
152+ config = angular . extend ( { } , defaultConfig , config ) ;
153+
149154 data = angular . extend ( {
150155 client_id : config . clientId ,
151156 grant_type : 'refresh_token' ,
@@ -181,7 +186,10 @@ function OAuthProvider() {
181186 * @return {promise } A response promise.
182187 */
183188
184- revokeToken ( data , options ) {
189+ revokeToken ( data , options , config ) {
190+ //Override default Oauth config
191+ config = angular . extend ( defaultConfig , config ) ;
192+
185193 var refreshToken = OAuthToken . getRefreshToken ( ) ;
186194
187195 data = angular . extend ( {
0 commit comments