I need to send these parameters to domain
domain/page?param1=xxx¶m2=yyy%26zzz
I am using proxy in wso2 for domain
localhost:8280/services/proxyfordomain/page?param1=xxx¶m2=yyy%26zzz
Endpoint of proxyfordomain is domain
Proxy is replacing %26 with &
Actual URL to be logged in console is:
To domain/page?param1=xxx¶m2=yyy%26zzz
But URL logged in console is :
To domain/page?param1=xxx¶m2=yyy&zzz
Here param2 will take yyy%26zzz format values
but not yyy&zzz
How to stop WSO2 from replacing?
Thanks for spending your valuable time
You can use the following script mediator configuration to replace 'yyy&zzz' with 'yyy%26zzz'.
<script language="js">var url = mc.getTo().toString();
var newURL = url.replace("yyy&zzz","yyy%26zzz");
mc.setTo(newURL);</script>
Related
I have a Flask web application which is hosting in Google Cloud Run which is hosted with https://mydomain.run.app.
Now I am trying to add google authentication to it. I have created the API under credentials in GCP. I have given https://mydomain.run.app/authorize in the redirect uri but when I tried to login from my app it throws me redirect mismatch error.
And the error shows me http://mydomain.run.app/authorize.
The mismatch is the https and http
When I tried to give http in the credentials uri it throws me
Invalid Redirect: This app has a publishing status of "In production". URI must use https:// as the scheme.
#app.route('/login/google')
def google_login():
google = oauth.create_client('google')
redirect_uri = url_for('authorize', _external=True,_scheme='https')
return google.authorize_redirect(redirect_uri)
#app.route('/authorize')
def authorize():
google = oauth.create_client('google')
token = google.authorize_access_token()
resp = google.get('userinfo')
user_info = resp.json()
user = oauth.google.userinfo()
session['profile'] = user_info
session.permanent = True
return redirect('/select')
Under Authorized redirect URIs
You should put 1 more URI :
https://mydomain.run.app/
Then check again. I have got same issue before.
your app is currently set to production in google developer console.
This means that all of the redirect uris you try to add to your project. Must be HTTPS and not HTTP you can also not use localhost
As you are trying to use http://mydomain.run.app/authorize you need to change it so that it is https://mydomain.run.app/authorize note that the first one was http:// and not https://
The error is coming because your application itself is trying to send a redirect uri of http and not https. You need to fix your application so that it is using https.
I need to catch the url parameters parsing in a get request by script mediator. I uses WSO2 esb 4.8.1. and I tried with the following js code. but it gives an error saying window is not defined.
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var requestNew="<m:ViW xmlns:m=\"wom\">
<m:request>
<RequestHeader>
<RemoteIP>dummyIp</RemoteIP>
<AppName>dummyAppName</AppName>
<AppPassword>dummyPassword</AppPassword>
<UserName>dummyUserName</UserName>
</RequestHeader>
<OrderId>23</OrderId>
<AccountNo>23</AccountNo>
<Cir>23</Cir>
<DocketNo>23</DocketNo>
<Status>23</Status>
<RequestType>23</RequestType>
<RequestedFrom>2016-04-19T22:47:37.000Z</RequestedFrom>";
requestNew=requestNew+"
<RequestedTo>"+getUrlVars()['RequestedTo']+"</RequestedTo>
</m:request>
</m:ViW>";
mc.setPayloadXML(new XML(requestNew));
So how can I access url parameter values in the wso2 esb script mediator?
Following blog will tell you how to do it. Its written targetting WSO2 API Cloud. But since synapse is used in both ESB and API Manager, its valid for your question as well. In summary,
To retrieve path parameters
var id = mc.getProperty('uri.var.id');
To retrieve query parameters
var mask = mc.getProperty('query.param.mask');
I am having trouble debugging a classic asp file in which I call a .NET web service. I am hoping that I can use Fiddler to see why the HTTP request to the web service is returning a 'Bad Request' error. I have a console application to request the classic asp file. Within the classic asp file I call the web service. When I run Fiddler, I see the request to the asp file but not the request to the web service. There is just one line in Fiddler with the asp file request.
Any suggestions or advice to troubleshoot the asp file would be appreciated.
Below is the code to sends a GET request to the web service.
The response in the console application is:
Status: 200
Status text: OK
But the call to the web service does not appear in Fiddler, only the call to the asp file. The web service and asp file are on different servers.
Shouldn't I see this call to the web service on Fiddler?
I want to debug a POST request but first I must learn how to use Fiddler. :)
This is my console application that calls the asp page:
Uri aspPServiceUri = new Uri("http://<serverNameAndPath>/FirstPage.asp?<parameters>;");
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(aspPServiceUri);
httpWebRequest.Method = "GET";
HttpWebResponse resp = (HttpWebResponse)httpWebRequest.GetResponse();
Stream resStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
string strResponse = reader.ReadToEnd();
Console.WriteLine(strResponse);
reader.Close();
This the asp file:
Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
URL = "http://<serverName>:<port>/PService/PService.Paging.svc?WSDL"
httpRequest.Open "GET", URL, False
httpRequest.Send()
Dim strResult
Dim strStatusText
Response.ContentType = "text/xml"
strStatusText = "Status: " & httpRequest.status & vbCrLf & "Status text: " & httpRequest.statusText
Response.Write(vbCrLf & strStatusText & vbCrLf)
Assuming you are using IIS 7+ or a relatively recent version of IIS Express, add the following to your web.config file. If you don't already have a web.config, then add one.
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy autoDetect="False" bypassonlocal="False" proxyaddress="http://127.0.0.1:8888" usesystemdefault="False" />
</defaultProxy>
</system.net>
This configures Fiddler as a proxy, so all HTTP requests from the web app will be routed through Fiddler.
I created a web service and was able to send requests to it from a serverside Jaggery.js script with no problem. Then I created a WSDL Proxy Service inside WSO2 ESB and tested it using the "Try it!" feature.
After I redirected my serverside script from the original web service to its proxy inside ESB, I got the error in System Logs:
The endpoint reference (EPR) for the Operation not found is /services/BpmAdderProcessProxy.BpmAdderProcessProxyHttpSoap11Endpoint and the WSA Action = urn:anonOutInOpResponse. If this EPR was previously reachable, please contact the server administrator.
To see in detail what was happening I activated the "SOAP Message Tracer" of the ESB. Suddenly my serverside script could access the webservice via my ESB proxy. Then I deactivated the "SOAP Message Tracer" and the error message was back again. Is my serverside script correct? Or does the debugging tool modify behavior of debugged code?
I'm a JavaScript developer. Actually Jaggery and UES are targeted at people like me. I'm not supposed to look inside Java code, am I? Is there a forum where JavaScript developers discuss WSO2 UES and Jaggery?
My serverside code is as follows:
<%
var x = request.getParameter("x");
var y = request.getParameter("y");
//var sum = parseInt(x) + parseInt(y);
var sum = add(parseInt(x), parseInt(y));
response.content = {
success: true,
data: {
result: sum
}
};
function add(x, y) {
var ws = require('ws');
var stub = new ws.WSStub("http://02-128:8280/services/BpmAdderProcessProxy?wsdl");
var process = stub.services["BpmAdderProcessProxy"].operations["process"];
var payloadTemplate = process.payloadXML();
var payload = replaceQuestionMarks(payloadTemplate, arguments);
var resultXml = process.request(payload);
var resultValue = resultXml.children().text();
return parseInt(resultValue);
}
function replaceQuestionMarks(template, values) {
var i = 0;
return template.replace(
/\?/g,
function() {
return values[i++];
}
);
}
%>
In ESB v4.8.1, pass-through transport is enabled by default and it does not support SOAP body based dispatching (it does not build the message so it can't acces the body's first element to find the operation)
You can append the operation name to the endpoint url : http://host:8280/services/BpmAdderProcessProxy/OperationName
You can add this parameter in your proxy conf (BpmAdderProcessProxy) in WSO2 ESB : <parameter name="disableOperationValidation" locked="false">true</parameter>
You can edit wso2esb/repository/conf/axis2/axis2.xml and replace <handler class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher" name="SOAPMessageBodyBasedDispatcher"/>
with
<handler class="org.apache.synapse.core.axis2.SynapseSOAPMessageBodyBasedDispatcher" name="SOAPMessageBodyBasedDispatcher"/>
Google Analytics is not understanding a URL Percent-encoding so I can track multiple domains between my "source" domain and my "destination" domain. I'm using Google Tag Manager + the new Universal Analytics.
Is there a macro or rule in google tag manager that I can create to help Google Analytics detect these two URL Percent-encoding as %2526 for & and %253d for = appropriately? If so, is there any support that could be provided with this issue I'm experiencing?
Here is an example URL (not real):
http://subdomain.example.com/adfs/ls/?wa=wsignin1.0&wtrealm=https%3a%2f%2fsub.domain.com%2fwebsite%2f&wctx=rm%3d0%26id%3dpassive%26ru%3d%252fwebsite%252fsite%252fexample%252f%253fstuff%253dtypeofuser%2526_ga%253d1.244536837.1471787898.1397850931&wct=2014-04-18T20%3a14%3a54Z
As you can see close to the tail end of URL contains my _ga cookie that originated from my "source" domain and is getting passed to my "destination" domain. This is a good thing, however GA is not able to read it, because of the URL Percent-encoding shown below:
%2526_ga%253d1.244536837.1471787898.1397850931
%2526 is a URL encode for &
%253d is a URL encode for =
Since google analytics is not able to translate the URL Percent-encoding %2526 and %253d it writes a brand new cookie instead when I look at my cookies when I debug using firebug > cookies tab.
The solution I found that solves this problem is to append the cookie to the URL again on page load so so the cookie can be read by google analytics.
The regex for .match can be customized with your URLs that you need to filter.
var gacookie = window.location.search.match('_ga%253d(.+)&wct=');
var url = window.location.href;
if (url.indexOf('_ga') > -1) {
url += '&_ga=' + gacookie[1]
parent.location.hash = url
var hash = location.hash.replace('#', gacookie[1]);
if(hash != '') {
location.hash = '&_ga=' + gacookie[1];
}
}