gpt4 book ai didi

java - 解析: Unauthorized when querying ParseInstallation

转载 作者:行者123 更新时间:2023-11-30 08:05:03 25 4
gpt4 key购买 nike

我有此代码可通过 Parse 中的 uniqueId 自定义字段查询安装:

public static void init(Context context) {
Parse.initialize(context, Constants.PARSE_APP_ID, Constants.PARSE_APP_KEY);

String wifiMacAddress = getWifiMacAddress(context);

ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
query.whereEqualTo("uniqueId", wifiMacAddress);
query.findInBackground(new FindCallback<ParseInstallation>() {
@Override
public void done(List<ParseInstallation> parseInstallations, ParseException e) {
if (parseInstallations == null)
throw new RuntimeException(e);
Log.d("prova", "Size: " + parseInstallations.size());
}
});
}

但是我得到了一个ParseRequestException:

java.lang.RuntimeException: com.parse.ParseRequest$ParseRequestException: unauthorized

我正在使用解析主 key 。如果我改用客户端 key ,则会收到此错误:

java.lang.RuntimeException: com.parse.ParseRequest$ParseRequestException: Clients aren't allowed to perform the find operation on the installation collection.

我做错了什么?

最佳答案

也许您有意这样做,但是方法 Parse.initialize(Context, String, String)

This method is only required if you intend to use a different applicationId or clientKey than is defined by com.parse.APPLICATION_ID or com.parse.CLIENT_KEY in your AndroidManifest.xml.

因此默认情况是在 AndroidManifest.xml 中定义两者,如下

<manifest ...>

...

<application ...>
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="@string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="@string/parse_client_key" />

...

</application>
</manifest>

并使用initialize(Context context)

顺便说一句,initialize预计

The client key provided in the Parse dashboard.

关于java - 解析: Unauthorized when querying ParseInstallation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31240185/

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