I am surprised that when I submit a variable with an identical string value it is rejected when the string is accepted in google oauth
For example
$client->setClientSecret('xDDDDDDD-Tcdfgtrrfftr');
is accepted where with the same string value stored in the variable as follows
$client->setClientSecret('{$domain->GooglePlusSecret}');
is rejected.
Anyway to write this to get around it? I serve multiple domains through the same root folder and software and want to set up for individual oauths as well ???
I'm assuming you're using PHP here, since that's what your code looks like.
Single quoted strings do not have variables interpreted. The reason your OAuth token doesn't work is because you are using the literal string {$domain->GooglePlusSecret}.
You should change your code to either $client->setClientSecret($domain->GooglePlusSecret); or $client->setClientSecret("{$domain->GooglePlusSecret}");.
Related
This is my route. I want to send a file to an Azure blob. I want to set the name of the blob as the file name without extension. I also want to filter out the whitespaces from the file names. I am thinking of using an interceptor
from("file://C:/camel/source1").recipientList(simple("azure-blob://datastorage/container1/${header.fileName}?credentials=#credentials&operation=updateBlockBlob"))
I want to invoke the interceptor only for updateBlockBlob operatin
interceptSendToEndpoint("^(azure-blob:).+(operation=updateBlockBlob)").setHeader("fileName",simple("${file:onlyname.noext}")).convertBodyTo(File.class)
The above code works with interceptFrom().
I tried replacing the regular expression with wild card like azure* i.e interceptSendToEndpoint("azure*"). It did not work
Whats wrong with the above code? Is it because of recipientList?
Also what features does simple have to remove white space?
Is there a better way to generate blob names dynamically?
Here is the documentation from camel on interceptors.
http://camel.apache.org/intercept.html
interceptFrom that intercepts incoming Exchange in the route.
interceptSendToEndpoint that intercepts when an Exchange is about to
be sent to the given Endpoint.
So I suspect the Exchange is already formed and camel expects the url to be resolved.
So the header needs to be set before the exchange is created for the Azure end point.
I did the following. To set the header, I use the interceptFrom, and to convert the object into File I used the inteceptSendToEndPoint
interceptSendToEndpoint("^(azure-blob:).+(operation=updateBlockBlob)").convertBodyTo(File.class)
interceptFrom().setHeader("fileName",simple("${file:onlyname.noext}".replaceAll("[^a-zA-Z\d]")))
Managed to get rid of the whitespace too
I am sending a signup activation email containing a signup confirmation url with a confirmation token that points to an angular front end app:
...
Activate
...
Note that the token is a JWT and is fairly long.
This works find for most users, but for some clicking on the link takes them to https://domain/com only without the confirm-signup?token=...
It seems as though the mail client may be stripping off everything after the #, but I can't find any evidence of others having this problem, nor can I reproduce it.
My best guess so far is that some mail clients are seeing the # and somehow treating the trailing part as an internal anchor and stripping it...?
Has anyone else encountered this sort of problem? If so, have you found any solution short of replacing the whole mechanism with something else?
Some clients treat the hash-link just fine. Others don't. There's a conversation about Outlook being dirty about this here: Outlook strips URL hash from email
What we did to resolve this at our company is simply create a handler on our server that redirects. Your email link would become http://domain.com/email-link?url=https%3A%2F%2Fdomain.com%2F%23%2Fconfirm-signup%3Ftoken%3D1234 and your server side script would grab the query param url and immediately trigger a redirect.
You'd need to make sure that you find all links in your emails and replace them. Here's a PHP function for that, but you could do this in whatever backend language you're using. Regex here may be helpful at least.
function replaceLinks($html,$hash) {
return preg_replace_callback('/<a [^>]*href=[\"\']{1}(.+?)[\"\\\']{1}/', function($matches) use ($hash) {
return str_replace($matches[1],"http://domain.com/email-link?url=".rawurlencode($matches[1]),$matches[0]);
}, $html);
}
Yes I have encountered this issue before because of the #, I was trying to link to a anchor on a landingpage.. My solution ended up using a short.url service to "hide" the # from the html e.g. https://goo.gl/
Looks like you need percent encoding!
A lot of times when your href gets parsed (by angular in this case) it doesn't handle the special characters right, or strips them. Find your problem characters and replace them with %3F for ?, %26 for &, and %23 for #. The rest are in a chart in the link.
Once the encoded address hits the browser the url will be decoded in your url bar.
I'm building a small webapplication which should store urls as input of a form. Sometimes urls can have attributes, parameters etc. like https:/www.stackoverflow.com/search?q=This+could+be+a+very+long+string. But some 'experts' could make use out of the missing validator, which checks the length of the string. Otherwise a limitation would may let occur an error if the url is to long.
I'm using for now SQLite3, but the solution should work database-independent.
When I was working with angular cookies, I found out that only strings are accepted by $cookies and stored in browser's cookie when set. i.e
If I set the following cookies
$cookies.id = 12345;
$cookies.name = "Prasad";
Only $cookies.name is set in the browser. So I had to change it to
$cookies.id = "12345";
to make it work.
here is the fiddle link to show the demo.
I've tried to check the angular source code to see why and found that they are deliberately checking for the value to be isString.
Is there any specific reason why they are accepting only string values. Couldn't we just allow integers also and convert to string while adding to browser cookie.
Thanks!
The main reason is probably that that the value of a cookie is always stored as a string in the browser. Sure, Angular could allow you to save it as an int when using the service and then just convert it before creating the cookie, the problem is that people would then assume that when they read that cookie later on the value would still be an int (that's how they saved it after all).
It wouldn't, it would be a string.
Angular seems to reason (I personally agree) that it is better to be strict up front. Force input to be the same as output so that people don't misunderstand what they will be getting back when they read the cookie.
I'm using Jsoup to connect to a URL with a space in it but keep getting a URI syntax error. Any ideas on how deal with this?
Thanks!!
You should percent-encode URLs. Space is represented as %20.
Additionally, some characters/symbols are used as delimiters in URLs (&, ?, =, etc.) and thus they cannot be put in the URL unless they are meant as delimiters. For example, if you wanted to pass the string "1 &1" I would have to encode it as "1%20%261" or else it will not parse properly.
See http://en.wikipedia.org/wiki/Percent-encoding for more details.
URLs cannot have spaces, by RFC1738 (section 2.2): http://www.ietf.org/rfc/rfc1738.txt
For some additional background on how to handle this, see: http://www.w3schools.com/tags/ref_urlencode.asp
In particular, one mechanism for encoding URLs can be found at:
HTTP URL Address Encoding in Java