MoralisWeb3 / unity-web3-game-kit

Unity Web3 Game Kit is the fastest way to connect and build games for Web3. It provides a single workflow for building high performance dapps. Fully compatible with your favourite platform.
MIT License
537 stars 219 forks source link

Error: HTTP/1.1 403 Forbidden {"error":"unauthorized"} #125

Closed Khaldi-Anouar closed 1 year ago

Khaldi-Anouar commented 2 years ago

Hello, we were using Moralis for 5-6 months, everything works fine, we're working on WebGL game, our builds was working fine with unity 2020 and above, till decided to upgrade the unity version to 2021, we're having a problem and we're trying to fix it long time ago! the problem is happening when we try to login we're getting this error:

error

the problem is this problem is not happening on all devices and all browsers, for example if there's a windows where this game can work finely on chrome, and this game couldn't be work on other windows on chrome we figures out that the x-parse-application-id (in request header) is missing in the browsers in which we're getting the error!

x-app

Nb. when we create new empty project and we import the Moralis assets then we take build, we're getting the same error with Unity 2021.3.7f1, but it works fine with Unity 2020. Can you help us to fix the problem?

Unity version: 2021.3.7f1 Web3 Game Kit version: v1.2.7 Development platform: Windows Build platform: WebGL

KoenRijpstra commented 2 years ago

@Khaldi-Anouar Thanks for your report. Our team will see if this is something we can fix or maybe is a Unity 2021.3 bug.

KoenRijpstra commented 2 years ago

@Khaldi-Anouar I did a test with Unity 2021.3.8f1 and using Chrome version 105.0.5195.52 (Officiële build) (64-bits) and all seems to be working. Maybe Unity 2021.3.7f1 has a issue. Could you test with version 2021.3.8f1?

Khaldi-Anouar commented 2 years ago

@Khaldi-Anouar I did a test with Unity 2021.3.8f1 and using Chrome version 105.0.5195.52 (Officiële build) (64-bits) and all seems to be working. Maybe Unity 2021.3.7f1 has a issue. Could you test with version 2021.3.8f1?

Hello, I tried with unity 2021.3.8f1 (Empty project with moralis), it doesn't work can you try on different browsers please?

KoenRijpstra commented 2 years ago

Which browser are you using? Does the introduction scene work?

Khaldi-Anouar commented 2 years ago

@KoenRijpstra yeah everything works fine until I click on connect and I sign with Metamask this is the build link https://crimin.itch.io/newmoralis

KoenRijpstra commented 2 years ago

Which browser are you testing on?

Khaldi-Anouar commented 2 years ago

More than one browser! chrome, opera, edge, brave, in some computers it's working on them all, is some computers it working only in some of them, in some computers it doesn't work on all of them

KoenRijpstra commented 2 years ago

@Khaldi-Anouar We tested on multiple browser and can't replicate the issue. If it is working on some computers and not on others what is the difference between those computers?

newbiedev1 commented 2 years ago

Same problem: https://forum.moralis.io/t/unity-moralis-v1-2-7-unauthorized-problem/19297/10 I am using Unity 2021.3.9f1 (latest stable) and i created empty project. And i added moralis v1.2.7 (latest). Also, i created ropsten test server with moralis. But when i try to connect with my metamask wallet, it has many errors. How can i fix? Note: I am trying on Unity Editor. image

newbiedev1 commented 2 years ago

@Khaldi-Anouar I did a test with Unity 2021.3.8f1 and using Chrome version 105.0.5195.52 (Officiële build) (64-bits) and all seems to be working. Maybe Unity 2021.3.7f1 has a issue. Could you test with version 2021.3.8f1?

I installed 2021.3.8f1 and tried with moralis v1.2.7 sdk on Unity Editor. But it's not working. Wallet cannot connect. image

KoenRijpstra commented 2 years ago

@Khaldi-Anouar @newbiedev1 Which version of the Moralis server is your dapp running? You can find it in your admin dashboard: image

newbiedev1 commented 2 years ago

@Khaldi-Anouar @newbiedev1 Which version of the Moralis server is your dapp running? You can find it in your admin dashboard: image I am using v0.0.385 server version. Also, i tried with moralis v1.1.0 and wallet connection is working on Unity Editor. But latest moralis sdks are not working (i tried with v1.2.5 and v1.2.7).

Khaldi-Anouar commented 2 years ago

@newbiedev1 same like you version, my version is v0.0.385

newbiedev1 commented 2 years ago

@Khaldi-Anouar @newbiedev1 Which version of the Moralis server is your dapp running? You can find it in your admin dashboard: image I am using v0.0.385 server version. Also, i tried with moralis v1.1.0 and wallet connection is working on Unity Editor. But latest moralis sdks are not working (i tried with v1.2.5 and v1.2.7).

Unity version: 2021.3.8f1 Moralis SDK version: v1.2.7 Server version: v0.0.385 i created empty project. And i added moralis v1.2.7 (latest). Also, i created ropsten test server with moralis. But when i try to connect with my metamask wallet, it has many errors. I have no problem with moralis v1.1.0 sdk.

image image image

newbiedev1 commented 2 years ago

Isn't there a solution?

xactant commented 2 years ago

At this time we have tried every combination given to us and we have not been able to replicate this issue.

Please do this:

  1. Open your project in Visual Studio.
  2. In the Solution Explorer, find and open this file: Packages / io.moralis.web3-unity-sdk / Runtime / Core / Platform / Services / MoralisCommandRunner.cs
  3. Go to line 60 Tuple<Status, string> cmdResult = await GetWebClient().ExecuteAsync(cmd); //, uploadProgress, downloadProgress, cancellationToken);
  4. Go to line 60: Tuple<Status, string> cmdResult = await GetWebClient().ExecuteAsync(cmd);
  5. Add this code:
    foreach (KeyValuePair<string, string> kvp in cmd.Headers)
            { 
                Debug.Log($"{kvp.Key}: {kvp.Value}");
            }

    5a. If the Debug is not found, add a using UnityEngine; statement at the top of the file.

  6. Run the app.
  7. At authentication, if you receive the error, check the Console log.
  8. If the headers were logged, please copy these as TEXT and post them in a new comment.
  9. If the headers were not logged something else is going on. Please go to your Moralis Server logs. If there are errors please copy the last error logged in a new comment.

Thank you.

newbiedev1 commented 2 years ago

At this time we have tried every combination given to us and we have not been able to replicate this issue.

Please do this:

  1. Open your project in Visual Studio.
  2. In the Solution Explorer, find and open this file: Packages / io.moralis.web3-unity-sdk / Runtime / Core / Platform / Services / MoralisCommandRunner.cs
  3. Go to line 60 Tuple<Status, string> cmdResult = await GetWebClient().ExecuteAsync(cmd); //, uploadProgress, downloadProgress, cancellationToken);
  4. Go to line 60: Tuple<Status, string> cmdResult = await GetWebClient().ExecuteAsync(cmd);
  5. Add this code:
foreach (KeyValuePair<string, string> kvp in cmd.Headers)
            { 
                Debug.Log($"{kvp.Key}: {kvp.Value}");
            }

5a. If the Debug is not found, add a using UnityEngine; statement at the top of the file. 6. Run the app. 7. At authentication, if you receive the error, check the Console log. 8. If the headers were logged, please copy these as TEXT and post them in a new comment. 9. If the headers were not logged something else is going on. Please go to your Moralis Server logs. If there are errors please copy the last error logged in a new comment.

Thank you.

Thank you for reply. Debug.log:

Content-Type: application/json UnityEngine.Debug:Log (object) MoralisUnity.Platform.Services.ClientServices.MoralisCommandRunner1/<RunCommandAsync>d__17<MoralisUnity.Platform.Objects.MoralisUser>:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/MoralisCommandRunner.cs:64) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2<MoralisUnity.Platform.Services.ClientServices.MoralisCommandRunner1/<RunCommandAsync>d__17<MoralisUnity.Platform.Objects.MoralisUser>, System.Tuple2<System.Net.HttpStatusCode, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.AwaiterActions:Continuation (object) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTask.cs:21) Cysharp.Threading.Tasks.UniTaskCompletionSourceCore1<System.Tuple2<System.Net.HttpStatusCode, string>>:TrySetResult (System.Tuple2<System.Net.HttpStatusCode, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTaskCompletionSource.cs:139) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2<MoralisUnity.Platform.Services.UniversalWebClient/d7, System.Tuple2<System.Net.HttpStatusCode, string>>:SetResult (System.Tuple2<System.Net.HttpStatusCode, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:328) MoralisUnity.Platform.Services.UniversalWebClient/d7:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/UniversalWebClient.cs:114) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2<MoralisUnity.Platform.Services.UniversalWebClient/<ExecuteAsync>d__7, System.Tuple2<System.Net.HttpStatusCode, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.Internal.PooledDelegate`1:Run (UnityEngine.AsyncOperation) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/Internal/PooledDelegate.cs:46) UnityEngine.AsyncOperation:InvokeCompletionEvent ()

image

newbiedev1 commented 2 years ago

I tested Unity 2021.3.3f1, 2021.3.4f1, 2021.3.8f1, 2021.3.9f1, 2020.3.0f1. Also, i used moralis sdk 1.2.5 and 1.2.7. Same error on all of them. But , i have tested with moralis old sdk (v1.1.0) and unity 2021.3.9f1, there is no problem. Wallet connection is working.

First error: Target: https://dhwor46zhuia.usemoralis.com:2053/server/users UnityEngine.Debug:LogError (object) MoralisUnity.Platform.Services.UniversalWebClient/d7:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/UniversalWebClient.cs:87) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Platform.Services.UniversalWebClient/d7, System.Tuple2<System.Net.HttpStatusCode, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.Internal.PooledDelegate1:Run (UnityEngine.AsyncOperation) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/Internal/PooledDelegate.cs:46) UnityEngine.AsyncOperation:InvokeCompletionEvent ()

Second error: Error: HTTP/1.1 403 Forbidden {"error":"unauthorized"} UnityEngine.Debug:LogError (object) MoralisUnity.Platform.Services.UniversalWebClient/d7:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/UniversalWebClient.cs:88) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Platform.Services.UniversalWebClient/d7, System.Tuple2<System.Net.HttpStatusCode, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.Internal.PooledDelegate1:Run (UnityEngine.AsyncOperation) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/Internal/PooledDelegate.cs:46) UnityEngine.AsyncOperation:InvokeCompletionEvent ()

Warning error: LogInAsync failed: {"error":"unauthorized"} UnityEngine.Debug:Log (object) MoralisUnity.Platform.Services.ClientServices.MoralisUserService1/<LogInAsync>d__19<MoralisUnity.Platform.Objects.MoralisUser>:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/MoralisUserService.cs:106) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2<MoralisUnity.Platform.Services.ClientServices.MoralisUserService1/<LogInAsync>d__19<MoralisUnity.Platform.Objects.MoralisUser>, MoralisUnity.Platform.Objects.MoralisUser>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.AwaiterActions:Continuation (object) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTask.cs:21) Cysharp.Threading.Tasks.UniTaskCompletionSourceCore1<System.Tuple2<System.Net.HttpStatusCode, string>>:TrySetResult (System.Tuple2<System.Net.HttpStatusCode, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTaskCompletionSource.cs:139) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2<MoralisUnity.Platform.Services.ClientServices.MoralisCommandRunner1/d17, System.Tuple2<System.Net.HttpStatusCode, string>>:SetResult (System.Tuple2<System.Net.HttpStatusCode, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:328) MoralisUnity.Platform.Services.ClientServices.MoralisCommandRunner`1/d17:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/MoralisCommandRunner.cs:88) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2<MoralisUnity.Platform.Services.ClientServices.MoralisCommandRunner1/d17, System.Tuple2<System.Net.HttpStatusCode, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.AwaiterActions:Continuation (object) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTask.cs:21) Cysharp.Threading.Tasks.UniTaskCompletionSourceCore1<System.Tuple2<System.Net.HttpStatusCode, string>>:TrySetResult (System.Tuple2<System.Net.HttpStatusCode, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/UniTaskCompletionSource.cs:139) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Platform.Services.UniversalWebClient/d7, System.Tuple2<System.Net.HttpStatusCode, string>>:SetResult (System.Tuple2<System.Net.HttpStatusCode, string>) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:328) MoralisUnity.Platform.Services.UniversalWebClient/d7:MoveNext () (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/UniversalWebClient.cs:114) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2<MoralisUnity.Platform.Services.UniversalWebClient/d7, System.Tuple2<System.Net.HttpStatusCode, string>>:Run () (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:313) Cysharp.Threading.Tasks.Internal.PooledDelegate1:Run (UnityEngine.AsyncOperation) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/Internal/PooledDelegate.cs:46) UnityEngine.AsyncOperation:InvokeCompletionEvent ()

Third error: NullReferenceException: Object reference not set to an instance of an object MoralisUnity.Platform.Services.ClientServices.UserServiceExtensions.LogInWithAsync[TUser] (MoralisUnity.Platform.Abstractions.IServiceHub1[TUser] serviceHub, System.String authType, System.Collections.Generic.IDictionary2[TKey,TValue] data, System.Threading.CancellationToken cancellationToken) (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Platform/Services/ClientServices/UserServiceExtensions.cs:202) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2[TStateMachine,T].GetResult (System.Int16 token) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:342) MoralisUnity.MoralisClient.LogInAsync (System.Collections.Generic.IDictionary2[TKey,TValue] data, System.Threading.CancellationToken cancellationToken) (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/MoralisClient.cs:221) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask2[TStateMachine,T].GetResult (System.Int16 token) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:342) MoralisUnity.Moralis.LogInAsync (System.Collections.Generic.IDictionary2[TKey,TValue] authData, System.Int32 chainId) (at Packages/io.moralis.web3-unity-sdk/Runtime/Core/Moralis.cs:320) Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`2[TStateMachine,T].GetResult (System.Int16 token) (at Packages/io.moralis.web3-unity-sdk/Runtime/External/UniTask/Runtime/CompilerServices/StateMachineRunner.cs:342) MoralisUnity.Kits.AuthenticationKit.AuthenticationKit.WalletConnect_SignAndLoginToMoralis (WalletConnectSharp.Unity.WalletConnectUnitySession session) (at Packages/io.moralis.web3-unity-sdk/Runtime/Kits/AuthenticationKit/Scripts/AuthenticationKit.cs:387) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) (at <6073cf49ed704e958b8a66d540dea948>:0) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0) UnityEngine.UnitySynchronizationContext.Exec () (at :0) UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at :0)

newbiedev1 commented 2 years ago

At this time we have tried every combination given to us and we have not been able to replicate this issue.

Please do this:

  1. Open your project in Visual Studio.
  2. In the Solution Explorer, find and open this file: Packages / io.moralis.web3-unity-sdk / Runtime / Core / Platform / Services / MoralisCommandRunner.cs
  3. Go to line 60 Tuple<Status, string> cmdResult = await GetWebClient().ExecuteAsync(cmd); //, uploadProgress, downloadProgress, cancellationToken);
  4. Go to line 60: Tuple<Status, string> cmdResult = await GetWebClient().ExecuteAsync(cmd);
  5. Add this code:
foreach (KeyValuePair<string, string> kvp in cmd.Headers)
            { 
                Debug.Log($"{kvp.Key}: {kvp.Value}");
            }

5a. If the Debug is not found, add a using UnityEngine; statement at the top of the file. 6. Run the app. 7. At authentication, if you receive the error, check the Console log. 8. If the headers were logged, please copy these as TEXT and post them in a new comment. 9. If the headers were not logged something else is going on. Please go to your Moralis Server logs. If there are errors please copy the last error logged in a new comment.

Thank you.

Are there any solution 🙂

Khaldi-Anouar commented 2 years ago

Hello @xactant I tried what you ask then I took a WebGL build, the headers are correct in both devices (device A where we can and device B where we can't login) both of them are giving the same debugs, but when I check the headers, there's some missing parameters x-parse-installation-id and x-parse-application-id This is the device A (or browser A) no missing headers: NoError This is the device B (or browser B) with missing headers

WithError
KoenRijpstra commented 2 years ago

@Khaldi-Anouar Does this only happen with users on Turkish networks?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.