Base64 encoding |
I am using the fusionAuth server and trying to send the server an address to send my user to once they are authenticated. I am setting the field like this:
$request["state"]["redirect_uri"] =urlEncode( "https://researchstudyonline.com:81/index.php/Configure/report_generator_amazing"); But I am getting an error from the server saying that there is "something wrong" with my url. This is the exact text: We're sorry, your request was malformed or was unable to be completed for some reason. Try hitting the back button and restarting the process to see if it fixes the problem. "error_description" : "Invalid redirect uri https%3A%2F%2Fresearchstudyonline.com%3A81%2Findex.php%2FConfigure%2Freport_generator_amazing", I noticed in some example the author created a function called base64URLEncode which seems to replace "_" and "-" and "". Underscores are clearly in my URL. Is there some built in function in CI3 for doing this type of encoding? Here is the function: Code: function base64URLEncode(str) { Is there any other type of encoding that you could recommend trying? I also tried $r$request["state"]["redirect_uri"] =base64_encode( "https://researchstudyonline.com:81/index.php/Configure/report_generator_amazing"); but that didn't work either.
proof that an old dog can learn new tricks
You do not want to use base64_encode.
php.net - urlencode Try reading that. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(09-19-2021, 12:45 AM)InsiteFX Wrote: You do not want to use base64_encode.
proof that an old dog can learn new tricks
urlencode actually seems different.
"Returns a string in which all non-alphanumeric characters except -_. have been replaced with a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs." I read this as urlencode is ignoring - and _. I need to modify these as per the code above. The base64URLEncode function above replaces both of these. What to do? I'd like to simulate this function in php. How? return str.toString('base64') .replace(/\+/g, '-') .replace(/\//g, '_') .replace(/=/g, ''); }
proof that an old dog can learn new tricks
Pure PHP
PHP Code: return str_replace(
Thanks. I am having a small problem with my server setup. I'll try it out as soon as I can!
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |