gpt4 book ai didi

azure-mobile-apps-client - invokeApi 未经授权

转载 作者:行者123 更新时间:2023-12-03 04:29:29 25 4
gpt4 key购买 nike

设置:

使用 js 库并遵循我的 C# Xamarin 项目的客户端登录/身份验证流程。
CORS 已设置并且初始登录正常:

this.client = new WindowsAzure.MobileServiceClient(<endpoint>);
this.client.login(<provider>);

我存储返回的“userId”和“mobileServiceAuthenticationToken”以供将来使用。

问题:

调用azure-mobile-apps-client的invokeApi:

this.client.invokeApi("myCustomerController", { method: 'GET' })

返回:

401 (Unauthorized)

我错过了什么吗?我希望客户端准备好调用我的后端服务。

我尝试过登录后直接使用现有客户端,但没有成功。
设置新客户端的“userId”和“mobileServiceAuthentication token”时也会失败。

当从其他地方(例如 C# MobileServiceClient)调用时,我调用的自定义 ApiController 工作正常。

最佳答案

我认为登录将使客户端准备好使用,但在我的情况下并非如此。我必须调用登录,获取结果中返回的 userId 和 token ,然后在发出任何 future 请求之前手动设置 currentUser。

this.client = new WindowsAzure.MobileServiceClient("https://...");
this.client.currentUser = {
userId: "xxxxx",
mobileServiceAuthenticationToken: "xxxxx"}

关于azure-mobile-apps-client - invokeApi 未经授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38943371/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com