Facebook Auth with Flutter not giving key hashes due to error in the command

Viewed 261

I am building an app where there is a Facebook login and registration in it, so when I need to get the key hashes using this command

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\aasal\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64


on Window10 PowerShell the following error is being given to me:

+ ... ers\aasal\.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
+ ... asal\.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
    + FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline

NOTE :- I downloaded OpenSSL from this link https://code.google.com/archive/p/openssl-for-windows/downloads I have the latest Java jre1.8.0_241 downloaded from oracle's website. I ran the command from different paths, C:\ , Desktop, C:\Program Files (x86)\Java, and many others and the same error kept happening.

1 Answers

Running the external programs without & (call) operator gives the error. Without call operator the path is just taken as an ordinary string. Try this:

& "keytool.exe" -exportcert -alias androiddebugkey -keystore "C:\Users\aasal\.android\debug.keystore" | & "C:\OpenSSL\bin\openssl.exe" sha1 -binary | & "C:\OpenSSL\bin\openssl.exe" base64

Or stop-parsing symbol (--%) can be also used:

keytool.exe --% -exportcert -alias androiddebugkey -keystore "C:\Users\aasal\.android\debug.keystore" | C:\OpenSSL\bin\openssl.exe --% sha1 -binary | C:\OpenSSL\bin\openssl.exe --% base64
Related