-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] #46
Comments
Hello, good afternoon. I downloaded the application, and the same thing happened to me. I found out that etoro added a new header from an x-csrf-token call, which is currently not being sent. modify these 3 files and now it works correctly. Another thing I had to change is the version of the chrome driver, for a more current one Maybe I can help you. RequestUtils.kt import ok.work.etoroapi.client.browser.EtoroMetadata fun prepareRequest(path: String, auth: String, mode: TradingMode, credentials: EtoroMetadata): HttpRequest.Builder {
} fun prepareOkRequest(path: String, auth: String, mode: TradingMode, credentials: EtoroMetadata): Request.Builder {
} fun Double.round(decimals: Int): Double { EtoroBrowserContext.kt import org.openqa.selenium.chrome.ChromeDriver data class EtoroMetadata(val cookies: String, val token: String, val cToken: String, val lsPassword: String, val baseUrl: String, val domain: String) @component
} |
hi, appreciate your help but, it didn't work for me |
I´ve debugged this error and found that this request: returns: "error code: 1020 which causes" After a quick google search I found out that this is from cloudflare: Does someone have any ideas how to bypass this? |
Hey, check this one here: I assume: So always try to keep the user-agend and in kotlin equal to your installed chrome. We currently have issues again. I will update sync all values again and will post the update. |
Hey, small update...so we sync the agent used in the kotlin code with our browser one and it works fine again. So 100% related to the user-agent. |
Hey @loki919, thanks for your reply, it worked. |
Hey, nice work, but how would you approach this when running inside Docker? |
Hey guys, i was using the same build i modify the user agent which is 91 as i have chrome 91 and driver is also 91. 2021-06-27 02:35:53.581 WARN 2228 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'browserHttpClient': Unsatisfied dependency expressed through field 'userContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userContext': Invocation of init method failed; nested exception is kotlin.UninitializedPropertyAccessException: lateinit property userContext has not been initialized Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'browserHttpClient': Unsatisfied dependency expressed through field 'userContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userContext': Invocation of init method failed; nested exception is kotlin.UninitializedPropertyAccessException: lateinit property userContext has not been initialized |
@loki919 @ok24601 @claudio0603 is this build is working with v91 ? |
yeah any official updates on this or does anyone have a fork I can clone? :) |
I tried alot but this built is not working anymore for Chrome V91, Even not for older version. And no one help here :( |
by using swagger most of the calls are not working, Error Code : 1020 occur, even i put the user-agent too but still not working. |
We are currently working wih chromeV91. It works totaly fine. |
@loki919 If you don't mind will you please share the new build which works with V91. I tried it but it not works. I also changes the user agent in code from , but nothing happened. Here are the some changes i made it but it not works. 1st Changed : 2nd Changed : |
Hi guys, |
You will probably be fine to just log in as normal but steal those extra cookies from the browser (ie the CF ones)
…Sent from my Galaxy
-------- Original message --------
From: ok24601 ***@***.***>
Date: 03/07/2021 9:01 am (GMT+00:00)
To: ok24601/etoro-api ***@***.***>
Cc: WarlaxZ ***@***.***>, Comment ***@***.***>
Subject: Re: [ok24601/etoro-api] org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] (#46)
Hi guys,
Sorry for not responding so long. The error you got is because of Cloud flare protection. The only way to fix it for good is to make all REST calls using selenium drevier.executeScript. Example is here: https://github.com/ok24601/etoro-api/blob/master/src/main/kotlin/ok/work/etoroapi/client/browser/BrowserHttpClient.kt
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#46 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADO6YE526V3KK6C6GQ2MALDTV27VRANCNFSM45ASMYDQ>.
|
i'm using all cookies after login already |
Yes iam already did it with this. Thanks for the reply.. I already set lot of calls in working condition. Only Update Position is remaining. But sometime it gives an error due to injecting execute script in browser. Anyways but its working by using Selenium Execute Function. org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1] |
@WarlaxZ is it working for you same build without using selenium drevier.executeScript ? by using normal api calls with authorization token ? By the way it works only first 2 calls and than iam unable to do it. I don't know what happened. I tried alot but i found 1020 error. no matter what iam login with some other browser or not. But it gives an errror for most of the calls 1020 like getCash, getAssetInfo |
@ok24601 so you are planning to rewrite the API calls using executeScript? |
when trying to start the API today i was greeted by this line..
I tried updating the project files from 1.1.3 to 1.1.4, but allas this did not fix my problem.
might anyone know how to fix this?
full output in attatched file, but this is the 'caused by' list
error log.docx
Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:505) ~[json-20180813.jar!/:na]
at org.json.JSONObject.(JSONObject.java:215) ~[json-20180813.jar!/:na]
at org.json.JSONObject.(JSONObject.java:399) ~[json-20180813.jar!/:na]
at ok.work.etoroapi.client.UserContext.getAccountData(UserContext.kt:45) ~[classes!/:na]
at ok.work.etoroapi.client.UserContext.setupAuthorizationContext(UserContext.kt:36) ~[classes!/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.3.RELEASE.jar!/:5.2.3.RELEASE]
... 39 common frames omitted
The text was updated successfully, but these errors were encountered: