firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
822 stars 425 forks source link

Converting Shortlinks back #31

Closed AIGameStudio closed 7 years ago

AIGameStudio commented 7 years ago

Hi,

I create a shortlink by calling this API https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=key and posting to it the longDynamicLink.

I am able to receive the the deep link back when I open the through the short link. But i need to convert the short link back to long dynamic link so that i can access the link parameter in my long dynamic link.

Can somebody help in converting shortlink back to long dynamic link

I am using Unity3d

stewartmiles commented 7 years ago

You're not seeing the complete link on InviteReceivedEventArgs ?

https://github.com/firebase/quickstart-unity/blob/master/invites/testapp/Assets/TestApp/UIHandler.cs#L80

On Thu, Dec 29, 2016 at 7:34 AM, AIGameStudio notifications@github.com wrote:

Hi,

I create a shortlink by calling this API https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=key and posting to it the longDynamicLink.

I am able to receive the the deep link back when I open the through the short link. But i need to convert the short link back to long dynamic link so that i can access the link parameter in my long dynamic link.

Can somebody help in converting shortlink back to long dynamic link

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-unity/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/AFw1RCIciIMDLf8Waylekyyk02PrGvFuks5rM9L1gaJpZM4LXqE9 .

AIGameStudio commented 7 years ago

@stewartmiles No i am seeing the shortlink which was generated from the long dynamic link

This is what i am seeing "https://xxxxx.app.goo.gl/w7EYt3lsMzyVpaP32"

My long dynamic link was

https://xxxxx.app.goo.gl/?link=https%3a%2f%2fpsnow.co%2finvitation_to_table%3froomid%3dfast-and-furious%26subroomid%3dfast-and-furious-d70b1c8a-a2d7-467e-b685-9e6a2e643806%2f&apn=com.zigbee.pokersquare&ibi=com.zigbee.pokersquare

stewartmiles commented 7 years ago

That's a bummer, sounds like we should add a feature to get the redirect from the short link.

Anyway the workaround for the moment is to fetch the redirect header from the short link.

e.g http://stackoverflow.com/questions/704956/getting-the-redirected-url-from-the-original-url

If you want to test the redirect on the command line, e.g:

$ curl -s -I https://f87nv.app.goo.gl/a10w | awk '/Location:/ { print $2 }' http://firebase.google.com/dynamic-link-with-customparams?param1=bish&param2=bosh&utm_source=google&utm_medium=email&utm_campaign=yoyoyo

On Thu, Dec 29, 2016 at 8:44 AM, AIGameStudio notifications@github.com wrote:

@stewartmiles https://github.com/stewartmiles No i am seeing the shortlink which was generated from the long dynamic link

This is what i am seeing "https://xxxxx.app.goo.gl/w7EYt3lsMzyVpaP32"

My long dynamic link was

https://xxxxx.app.goo.gl/?link=https%3a%2f%2fpsnow.co% 2finvitation_to_table%3froomid%3dfast-and-furious%26subroomid%3dfast-and- furious-d70b1c8a-a2d7-467e-b685-9e6a2e643806%2f&apn=com. zigbee.pokersquare&ibi=com.zigbee.pokersquare

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-unity/issues/31#issuecomment-269657414, or mute the thread https://github.com/notifications/unsubscribe-auth/AFw1RKTcsoG3Wv1oxr61735xrTpL-K9Gks5rM-OGgaJpZM4LXqE9 .

AIGameStudio commented 7 years ago

I tried it and it works fine on Unity Editor. But when running on iOS i am getting this exception

Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in :0 Rethrow as WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in :0 at System.Net.HttpWebRequest.GetResponse () [0x00000] in :0 at LongDynamicUrl.GetFinalRedirectedUrl (System.String url, System.Action`1 onDynamicLinkFetched) [0x00000] in :0 at Firebase.Invites.FirebaseInvites+Listener.TrySendCachedMessage () [0x00000] in :0 at Firebase.AppUtil.PollCallbacks () [0x00000] in :0

stewartmiles commented 7 years ago

http://answers.unity3d.com/questions/1184815/how-to-stop-mono-from-preventing-authentication.html ?

On Thu, Dec 29, 2016 at 10:56 AM, AIGameStudio notifications@github.com wrote:

I tried it and it works fine on Unity Editor. But when running on iOS i am getting this exception

Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in :0 Rethrow as WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in :0 at System.Net.HttpWebRequest.GetResponse () [0x00000] in :0 at LongDynamicUrl.GetFinalRedirectedUrl (System.String url, System.Action`1 onDynamicLinkFetched) [0x00000] in :0 at Firebase.Invites.FirebaseInvites+Listener.TrySendCachedMessage () [0x00000] in :0 at Firebase.AppUtil.PollCallbacks () [0x00000] in :0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-unity/issues/31#issuecomment-269675929, or mute the thread https://github.com/notifications/unsubscribe-auth/AFw1RN8AlZO5csCnJmmplW-Q80EY9tYkks5rNAJDgaJpZM4LXqE9 .

AIGameStudio commented 7 years ago

Still same issue. My method to get the long dynamic url is

public static void GetFinalRedirectedUrl(string url, Action onDynamicLinkFetched) { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.AllowAutoRedirect = false; webRequest.Timeout = 10000; webRequest.Method = "HEAD"; HttpWebResponse webResponse; using (webResponse = (HttpWebResponse)webRequest.GetResponse()){ if ((int)webResponse.StatusCode >= 300 && (int)webResponse.StatusCode <= 399) { string uriString = webResponse.Headers["Location"]; onDynamicLinkFetched(uriString); }else { onDynamicLinkFetched(null); } webResponse.Close(); } }

Please tell me what to change make it work.

stewartmiles commented 7 years ago

Again see http://answers.unity3d.com/questions/1184815/how-to-stop-mono-from-preventing-authentication.html

http://answers.unity3d.com/questions/1112912/how-can-i-add-a-certificate-to-the-mono-trust-stor.html

Also, see http://answers.unity3d.com/questions/792342/how-to-validate-ssl-certificates-when-using-httpwe.html for a more Unity specific description.

On Thu, Dec 29, 2016 at 11:18 AM, AIGameStudio notifications@github.com wrote:

Still same issue. My method to get the long dynamic url is

public static void GetFinalRedirectedUrl(string url, Action onDynamicLinkFetched) { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.AllowAutoRedirect = false; webRequest.Timeout = 10000; webRequest.Method = "HEAD"; HttpWebResponse webResponse; using (webResponse = (HttpWebResponse)webRequest.GetResponse()){ if ((int)webResponse.StatusCode >= 300 && (int)webResponse.StatusCode <= 399) { string uriString = webResponse.Headers["Location"]; onDynamicLinkFetched(uriString); }else { onDynamicLinkFetched(null); } webResponse.Close(); } }

Please tell me what to change make it work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/quickstart-unity/issues/31#issuecomment-269679010, or mute the thread https://github.com/notifications/unsubscribe-auth/AFw1RAynQ34jpaCNIAekwDGSThfMptSxks5rNAd-gaJpZM4LXqE9 .

AIGameStudio commented 7 years ago

Adding this ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; before sending request worked

private static bool MyRemoteCertificateValidationCallback(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { bool isOk = true; if (sslPolicyErrors != SslPolicyErrors.None) { for (int i=0; i<chain.ChainStatus.Length; i++) { if (chain.ChainStatus [i].Status != X509ChainStatusFlags.RevocationStatusUnknown) { chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain; chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan (0, 1, 0); chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags; bool chainIsValid = chain.Build ((X509Certificate2)certificate); if (!chainIsValid) { isOk = false; } } } } return isOk; }

DO YOU THINK THERE WILL BE SOME SECURITY ISSUES.