I'm testing the WSO2 Identity server using the Oauth 2.0 with a Python login application. The routine which I adjusted from another IdP server, throws an error at the token authorization step, after successfully passing through step 1 which is obtaining the request code. The error returning from the WSO2 server is:
"Provided Authorization Grant is invalid"
Console Log
*** start of login ***
Code received = 23618215e0ee701b973f548a3f8e7dda
Token Request Answered = <Response [400]>
Token Request Text = {"error":"invalid_grant","error_description":"Provided Authorization Grant is invalid."}
Token Request URL = https://extbasicpacman05.podc.sl.edst.red.com:9443/oauth2/token
Token Request Encoding = None
Code:
#print "Send Token Request now"
# prepare lookup of token using code as input
verify='/home/claudef/tmp/oauth_2/oauth/wso2.pem'
url = "https://extbasicpacman05.podc.sl.edst.red.com:9443/oauth2/token"
payload = { 'client_id': client_id, 'client_secret': client_secret, 'grant_type': 'authorization_code', 'code': str(code), 'redirect_uri': 'http://localhost/resources/oauth2Callback' }
urllib.urlencode(payload)
headers = { 'application' : 'x-www-form-urlencoded' }
r = requests.post(url, data=payload, headers=headers, verify=verify)
print "Token Request Answered = " + str(r)
print "Token Request Text = " + str(r.text)
print "Token Request URL = " + str(r.url)
print "Token Request Encoding = " + str(r.encoding)
Any hint how to fix the authorization grant using a code value is welcome.