KoenZomers / RingRecordingDownload

Console Application for Windows, Raspberry Pi, Linux and macOS which allows for downloading of Ring recorded events
Apache License 2.0
20 stars 9 forks source link

[BUG] JsonException when trying to log in to account with 2FA enabled. #15

Closed DavidBerdik closed 1 year ago

DavidBerdik commented 1 year ago

Describe the bug When I try to use my Ring account which has 2FA enabled, I get a JsonException. I have not tested if this also happens when using an account with 2FA disabled.

Here is the output from an attempted execution of the application.

C:\Users\David\Downloads>RingRecordingDownload.exe -username <REDACTED> -password <REDACTED> -list

Ring Recordings Download Tool v2.2.0.0 by Koen Zomers

Connecting to Ring services
Authenticating using provided username and password
Two factor authentication enabled on this account, please enter the Ring token from the e-mail, text message or authenticator app:
<REDACTED>
Retrieving all devices... Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to KoenZomers.Ring.Api.Entities.MotionZone. Path: $.stickup_cams[0].settings.motion_zones | LineNumber: 0 | BytePositionInLine: 5073.
   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at KoenZomers.Ring.Api.Session.GetRingDevices()
   at KoenZomers.Ring.RecordingDownload.Program.Main(String[] args)
   at KoenZomers.Ring.RecordingDownload.Program.<Main>(String[] args)

To Reproduce Steps to reproduce the behavior:

  1. Attempt to log in to Ring account that has 2FA enabled.
  2. The application will return the error shown above.

Expected behavior The application should list the videos associated with the account.

Versions (please complete the following information):

KoenZomers commented 1 year ago

Can you try it again with version 2.3.0.0 and see if the issue is resolved in that?

matziq commented 1 year ago

Unfortunately, I get the same error with 2.3.0.0.

Retrieving all devices... Unhandled exception. System.Text.Json.JsonException: The JSON value could not be converted to System.String. Path: $.stickup_cams[0].motion_snooze | LineNumber: 0 | BytePositionInLine: 8795. ---> System.InvalidOperationException: Cannot get the value of a token type 'StartObject' as a string. at System.Text.Json.Utf8JsonReader.GetString() at System.Text.Json.Serialization.Converters.StringConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonCollectionConverter2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable1 actualByteCount) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at KoenZomers.Ring.Api.Session.GetRingDevices() at KoenZomers.Ring.RecordingDownload.Program.Main(String[] args) at KoenZomers.Ring.RecordingDownload.Program.

(String[] args) PS G:\Downloads\win-x64>

KoenZomers commented 1 year ago

Bweh running from one error to the next one :) Let me see if I can create a minimal version of the Ring model for this tool to avoid keep bumping into this kind of stuff.

DavidBerdik commented 1 year ago

I ended up using python-ring-doorbell to handle my use case, but for testing purposes, I gave this a try and it still did not work for me. The issue was the same as what @matziq described.

KoenZomers commented 1 year ago

Thanks for taking the time to test it regardless @DavidBerdik . Would you mind running it again with version 3.0.0.0 I've just released? I've got good faith that this one should finally resolve this issue.

DavidBerdik commented 1 year ago

@KoenZomers You're welcome! I just did a test download of the last week of footage from my camera and it worked!

matziq commented 1 year ago

Works great for me, too! Thanks, Koen!

On Sat, Sep 2, 2023 at 6:36 PM David Berdik @.***> wrote:

@KoenZomers https://github.com/KoenZomers You're welcome! I just did a test download of the last week of footage from my camera and it worked!

— Reply to this email directly, view it on GitHub https://github.com/KoenZomers/RingRecordingDownload/issues/15#issuecomment-1703981445, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHTD6PJUI2ROYSS3KB32HPDXYPNJVANCNFSM6AAAAAA3B7XUHY . You are receiving this because you were mentioned.Message ID: @.***>

ohadpr commented 1 year ago

This is happening with v3.1.0.0 Trying to login for the first time on a linux-x64, user+pass and the account has 2FA enabled.

Command:

./RingRecordingDownload -username blahblah -password blablah -list

Output:

Ring Recordings Download Tool v3.1.0.0 by Koen Zomers

Connecting to Ring services
Authenticating using provided username and password
Unhandled exception. System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at KoenZomers.Ring.Api.Session.Authenticate(String operatingSystem, String hardwareId, String appBrand, String deviceModel, String deviceName, String resolution, String appVersion, Nullable`1 appInstallationDate, String manufacturer, String deviceType, String architecture, String language, String twoFactorAuthCode)
   at KoenZomers.Ring.RecordingDownload.Program.Main(String[] args)
   at KoenZomers.Ring.RecordingDownload.Program.<Main>(String[] args)
Aborted (core dumped)