@@ -749,7 +749,8 @@ export const handleAuthorize = (
749749 setError ,
750750 setisAuthorized ,
751751 setIsLoading ,
752- setSnackbar
752+ setSnackbar ,
753+ btcbi
753754) => {
754755 if ( ! confTmp . clientId || ! confTmp . clientSecret ) {
755756 setError ( {
@@ -760,7 +761,8 @@ export const handleAuthorize = (
760761 }
761762
762763 setIsLoading ( true )
763- const apiEndpoint = `https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=${ confTmp . clientId } &prompt=login%20consent&redirect_uri=${ encodeURIComponent ( window . location . href ) } /redirect`
764+ const apiEndpoint = `https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=${ confTmp . clientId } &prompt=login%20consent&state=${ encodeURIComponent ( window . location . href ) } /redirect&redirect_uri=${ encodeURIComponent ( btcbi . api . base ) } /redirect`
765+
764766 const authWindow = window . open ( apiEndpoint , 'salesforce' , 'width=400,height=609,toolbar=off' )
765767 const popupURLCheckTimer = setInterval ( ( ) => {
766768 if ( authWindow . closed ) {
@@ -789,17 +791,34 @@ export const handleAuthorize = (
789791 } else {
790792 const newConf = { ...confTmp }
791793 newConf . accountServer = grantTokenResponse [ 'accounts-server' ]
792- tokenHelper ( grantTokenResponse , newConf , setConf , setisAuthorized , setIsLoading , setSnackbar )
794+ tokenHelper (
795+ grantTokenResponse ,
796+ newConf ,
797+ setConf ,
798+ setisAuthorized ,
799+ setIsLoading ,
800+ setSnackbar ,
801+ btcbi
802+ )
793803 }
794804 }
795805 } , 500 )
796806}
797807
798- const tokenHelper = ( grantToken , confTmp , setConf , setisAuthorized , setIsLoading , setSnackbar ) => {
808+ const tokenHelper = (
809+ grantToken ,
810+ confTmp ,
811+ setConf ,
812+ setisAuthorized ,
813+ setIsLoading ,
814+ setSnackbar ,
815+ btcbi
816+ ) => {
799817 const tokenRequestParams = { ...grantToken }
800818 tokenRequestParams . clientId = confTmp . clientId
801819 tokenRequestParams . clientSecret = confTmp . clientSecret
802- tokenRequestParams . redirectURI = `${ encodeURIComponent ( window . location . href ) } /redirect`
820+ tokenRequestParams . redirectURI = `${ btcbi . api . base } /redirect`
821+
803822 bitsFetch ( tokenRequestParams , 'selesforce_generate_token' ) . then ( result => {
804823 if ( result && result . success ) {
805824 const newConf = { ...confTmp }
0 commit comments