I am writing a python script to add links to my own Pocket account. I am following these steps.
- Get Consumer Key: I have a consumer key generated from Pocket developer app
Generate request token: I have generated a request token with below code
pocket_get_request_token_url = "https://getpocket.com/v3/oauth/request" headers = {"Content-Type": "application/json; charset=UTF-8", "X-Accept": "application/json"} params = {"consumer_key": consumer_key, "redirect_uri": "pocketapp1234:authorizationFinished"} pocketOAuth = requests.post(pocket_get_request_token_url, json=params, headers=headers) request_token = json.loads(pocketOAuth.text)["code"]
Authorize request token: Step 3 is to authorize the token using below code. I don't know how to run this block for a python script.
pocket_auth_request_token_url = "https://getpocket.com/auth/authorize" params = {"request_token": request_token, "redirect_uri": "pocketapp1234:authorizationFinished"} authResp = requests.post(pocket_auth_request_token_url, json=params)
Generate Access token: Step 4 is to then generate access token. If I go ahead and generate an access token, using the below code,
pocket_get_access_token_url = "https://getpocket.com/v3/oauth/authorize" headers = {"Content-Type": "application/json; charset=UTF-8", "X-Accept": "application/json"} params = {"consumer_key": consumer_key, "code": request_token} accessResp = requests.post(pocket_get_access_token_url, json=params, headers=headers) access_token = json.loads(accessResp.text)["access_token"]
When I run the above block of code, I get the below error.
x-error-code : 158 x-error : User rejected code
So my question is, If I am trying to add links to my pocket account using python script, I am obviously not running a web application, so how can I authorize the generated request token so that I can proceed to generate an access token?