Code Monkey home page Code Monkey logo

Comments (9)

peternied avatar peternied commented on July 17, 2024

@paya-cz debugging on my local machine, I get an authorization code that looks like #######-####-####-####-############, also the code seems to be encoded as hex which looks very different from what you are showing in your example. Where did you get your authorization code from?

If you are still having trouble figuring out what is going on, could you get a fiddler trace of the sample application running as this will allow me to quickly diagnose the problem.

from livesdk-for-windows.

paya-cz avatar paya-cz commented on July 17, 2024

@peternied as mentioned in the comment line just above the code, the authorization code is just a garbage that I put in myself. Whole purpose of that was to see how the library handles errors - in this case, how it would handle garbage auth code. Getting a standard exception would be so much preferred rather than a deadlock or exception in Application.Run. The code for handling this type of problems is already there, it just seems to not be implemented properly. In LiveAuthClientCore.cs, it properly executes this.codeExchangeTask.SetException(authResult.Error); in OnExchangeCodeCompleted event handler (it sets LiveAuthException in the SetException), but for a reason that's beyond me, the ExchangeAuthCodeAsync either fails in the end with a TargetInvocationException or enters a deadlock.

from livesdk-for-windows.

peternied avatar peternied commented on July 17, 2024

Analyzing how the program works with a bad login code, we should execute a request that returns an error inside of LiveLoginResult via the LiveAuthRequestUtility's RequestAccessToken method. Inside of LiveAuthClientCore, the continuation is called, which in turn causes the OnExchangeCodeCompleted function to be called, setting the exception on the task instead of the result. Now that we are back on MainForm.cs inside of OnAuthCompleted, we should get the exception at the resolution of the await result, which then triggers the exception to be logged to the ApiExplorer output window. (This is at least what I'm seeing).

Now if you change the await into a .Result, you are now resolving the task which causes a slightly different exception to be thrown, specifically AggregateException. But if you look into the inner aggregate exception you'll find the same Microsoft.Live.LiveAuthException that would normally have been caught by the try block that call is inside of. The reason you get a TargetInvocationException is that is how WinForm exceptions bubble out of applications. You can verify this behavior for yourself by adding catch (Exception e) {this.LogOutput(e.ToString());} at the bottom of that method. I've pushed this branch which contains this change https://github.com/peternied/LiveSDK-for-Windows/tree/BadAuthToken

As far as I can tell by the application design, you should get an error in that output window, and it should help you understand what is going wrong, and I can't find a deadlock or blocking issue that would prevent the application from working.

from livesdk-for-windows.

paya-cz avatar paya-cz commented on July 17, 2024

You are right, I am getting the same behavior now. I guess I must have just messed up somewhere else.

However, it seems there is another problem (unless I am tripping again). If I set a valid refresh token in MainForm.cs:RetrieveRefreshTokenAsync and I disconnect from the internet, then using the sample here on GitHub, I get NullReferenceException in LiveAuthRequestUtility.ReadResponse (invoked by RequestAccessToken, invoked by LiveAuthClient.InitializeAsync in MainForm_Load). However if I replace the bundled Live library with the one from NuGet, I don't get any exceptions, but the method never progresses beyond await InitializeAsync.

from livesdk-for-windows.

peternied avatar peternied commented on July 17, 2024

Hmm, not sure what is wrong there, as I don't seem to be able to repro your issue, if you could put up a repro on your personal fork I can give it a quick look.

from livesdk-for-windows.

paya-cz avatar paya-cz commented on July 17, 2024

Please take a look here https://github.com/paya-cz/LiveSDK-for-Windows/tree/exceptions

You will need your own refresh token for the 0000000048122D4E app. Be sure to disconnect from internet when you run the app.

from livesdk-for-windows.

peternied avatar peternied commented on July 17, 2024

Thanks! FYI - I'll take a look into this tomorrow.

from livesdk-for-windows.

peternied avatar peternied commented on July 17, 2024

Could you take a quick look and see if this resolves your problem? Btw thanks for the repro that helped a bunch narrow this issue down!

from livesdk-for-windows.

paya-cz avatar paya-cz commented on July 17, 2024

Thanks, it seems your commit fixed the issue. At least I haven't been able to find a way to break it again. :-) Cheers from Czech Republic!

from livesdk-for-windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.