I am currently working on an app that allows users to sign in through LinkedIn. I would like to get the user's email and am currently testing it through terminal using curl first. From LinkedIn's API documentation I am aware that I need to GET from this url:
https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))
to get the email of a user. I have already requested permission from my user for retrieving their email address. The curl command I run is as follows:
curl https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~)) -H "Authorization: Bearer access_token"
where access_token in reality is the actual access token. However every time I run this on terminal I always get this response:
[1] 31166
zsh: no matches found: https://api.linkedin.com/v2/emailAddress?q=members
zsh: unknown file attribute: h
[1] + exit 1 curl https://api.linkedin.com/v2/emailAddress?q=members
This is odd considering that my request to:
https://api.linkedin.com/v2/me
works perfectly fine. Does anyone know what might be a potential cause of this?
The &
in the URL is being parsed as a shell operator, running curl
in the background. You need to escape it, which is most easily done by quoting the entire URL.
curl 'https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))' \
-H "Authorization: Bearer access_token"
More completely, after the &
is parsed as a command terminator, you have the following two commands:
curl https://api.linkedin.com/v2/emailAddress?q=members &
projection=(elements*(handle~))' -H "Authorization: Bearer access_token"
In both cases, you have characters that result in zsh
attempting filename generation.
?
in the first one*
in the secondThe first command runs in the background, and immediately fails, because zsh
treats an unmatched pattern as an error, not literal text like bash
does by default.
The second command fails before a match is even attempted. The (
introduces a series of glob qualifiers, but h
is not a recognized qualifier.