API access issues.

Greetings,

While my account has the apropriate permissions to access the scope I need, it seems that when I send a POST request for a token the server does not recognise it as a POST request.

I am using python with the requests lib to try and access the API.
the code is as follows:
(note that treasure is a external file that keeps sensitive informatoin)
```python
# libs
import requests, secrets, hashlib
# files
import treasure
# simple post func
def send_post_request(url, data, header):
response = requests.post(url, data,json=None, headers=header)
return response

# scope
scope = "account:characters"
# random enough randomness
base64_encoded_privkey = secrets.token_bytes(32)
base64_encoded_pubkey = hashlib.sha256(base64_encoded_privkey).digest()
# header
header = {'Content-Type': 'application/x-www-form-urlencoded'
,'User-Agent':'OAuth ' + treasure.client_id +"/"+ treasure.version + " (contact: " + treasure.contact+")"
}
# API point
API_token_endpoint = "https://pathofexile.com/oauth/token"
request_data = {"client_id":treasure.client_id
,"client_secret":treasure.client_secret
,"grant_type":"client_credentials"
,"scope":scope
#, "code":base64_encoded_pubkey
}





if __name__ == '__main__':
response = send_post_request(API_token_endpoint,request_data, header)
#print(request_data)

print(response.history[0].request.method)
print(response.request.headers)
print(response.history[0].content)
print(response)
print(response.content)
```

what I get is (sensitive infomratoin redacted):
```
POST
{'User-Agent': 'OAuth [redacted]/[redacted] (contact: [redacted])', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}
<Response [405]>
b'{"error":"invalid_request","error_description":"The request method must be POST when creating a token"}'
```
Last bumped on Aug 27, 2024, 2:31:55 PM
Solved:
the issues was that the address has to be
https://www.pathofexile.com/ouath/token

the www is what I was missing.

Report Forum Post

Report Account:

Report Type

Additional Info