Error:"Missing \"grant_type\" parameter" when I send a post request to Token Endpoint OAuth2.0

Ka.M.925
Ka.M.925 Posts: 5 🔍

I'm trying to connect my webapp on brightspace page and use OAuth2.0 however my program keeps breaking at the token step. I get this error saying I'm missing grant_type even though I believe it is specified. I tried using Postman to check and got same issue.
Here is my python code:

token_params = {        'grant_type': 'authorization_code',        'client_id': CLIENT_ID,        'client_secret': CLIENT_SECRET,        'redirect_uri': REDIRECT_URI_ENCODE,        'code': code,    }
token_response = requests.post(TOKEN_ENDPOINT, data=token_params)
if token_response.status_code != 200: 
return jsonify({'error': token_response.json()})

and here is what i was sending in postman:
https://auth.brightspace.com/core/connect/token?grant_type=authorization_code&code=CODE&redirect_uri=ENCODED_REDIRECT_URI&client_id=CLIENT_ID&client_secret=CLIENT_SECRET

Please let me know if im doing anything wrong and how I can correct it. Thanks :)

Answers

  • Hi Ka,

    Thank you for contacting the community. Did you try the

    grant_type of client_credentials

    Section 4.1 in the IMS security spec is the relevant part of the spec. Our LTI developer FAQs also have some common errors when getting a token.