表达式或语句中出现意外的标记“ sha1”。用于为Facebook开发者帐户应用生成密钥哈希

时间:2019-01-17 11:13:05

标签: android facebook-graph-api

我正在尝试为集成了Facebook登录的应用生成密钥哈希

对于generationg密钥哈希,我正在根据facecook文档使用以下代码

> C:\Program Files\Java\jdk1.8.0_111\bin> keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Akash\.android \debug.keystore" |"C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64

但是它显示出如下错误:

At line:1 char:97
+ ... ers\Akash\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -b ...
+                                          ~~~~~~~~~~~~~~~~~~~~~~~~
Expressions are only allowed as the first element of a pipeline.
At line:1 char:122
+ ... kash\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary ...
+                                                              ~~~~
Unexpected token 'sha1' in expression or statement.
At line:1 char:137
+ ... :\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64
+                                           ~~~~~~~~~~~~~~~~~~~~~~~~
Expressions are only allowed as the first element of a pipeline.
At line:1 char:162
+ ... :\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64
+                                                                    ~~~~~~
Unexpected token 'base64' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

3 个答案:

答案 0 :(得分:4)

使用命令提示符。它将起作用。

答案 1 :(得分:0)

使用cmd并在下面尝试此代码。对我有用

1。首先下载并安装openssl(如果可能,请从git下载)
2.为openssl和java设置环境变量,然后尝试

keytool -exportcert -alias androiddebugkey -keystore "%USERPROFILE%\.android\debug.keystore" | "openssl" sha1 -binary | "openssl" base64

如果要求输入密码,请使用 android

答案 2 :(得分:-1)

不要在 Visual Studio Code 或 Android Studio 中使用终端,使用 PowerShell 或标准命令提示符。