AnsweredAssumed Answered

rest api refresh_token -how?

Question asked by jb31639 on Feb 28, 2019
Latest reply on Mar 5, 2019 by jb31639

Hi

I'm using a modified version of the python code available at:

GitHub - blackboard/BBDN-REST-DEMO_Python  

I'm creating groups and adding members, based on our timetable system.

It's working but I'm not happy about renewing the token as you have to keep checking the expiry time. I'd like refresh/renew the token a few minutes before it expires as this should speed things up.

 

I'd like to refresh the token at an appropriate time but I can't get it to work. The error I get is:

{"error":"invalid_grant","error_description":"Invalid refresh_token"}

 

The error makes sense but I'm not sure what to do? I want to refresh the token but get this error. Am I supposed to use different keys/secret?

 

My code is (using the auth.py above)

 

Note the API has changed so the endpoint is:

/learn/api/public/v1/oauth2/token


        self.PAYLOAD = {

            'token':self.TOKEN,

            'grant_type':'refresh_token',

            'refresh_token':self.TOKEN,

       }

 

This gives for example

 

              token:MVsSPDM2<REMOVED>G7nYFkq

              grant_type:refresh_token

              refresh_token:MVsSPDM2<REMOVED>G7nYFkq

 

 

The grant_type is 'refresh_token" and you can see I'm adding the current token to be refreshed.

 

I think the 'token' variable isn't required here but was testing with/without.

 

I think you can't create a new token until the current one as expired so you have to keep checking. It's not the end of the world but I'd like to estimate +/- 5 minutes of the expiry time and renew/refresh in good time.

 

Any suggestions?

 

Jason

Outcomes