Oauth2SessionManager.get_access_tokens returns invalid_grant
See original GitHub issueHello, I have following code
def connect(self, event):
qb_consumer_key=xxxxxxx
qb_consumer_secret=xxxxxxxxx
sandbox=True
base_url='https://quickbooks.api.intuit.com'
session_manager = Oauth2SessionManager(sandbox=sandbox,
client_id=qb_consumer_key,
client_secret=qb_consumer_secret,
base_url=base_url)
state_id = str(uuid.uuid4())
authorize_url = session_manager.get_authorize_url(callback_url,state=state_id)
state = {
"client_id":qb_consumer_key,
"client_secret":qb_consumer_secret,
"sandbox": sandbox,
"base_url":base_url
}
set_state(state_id, state) # stores the state data in cache
return authorize_url
def callback(event):
state = get_state(event['state']) #returns the state where state_id == event['state']
if state:
auth_code = event.get("code")
realm_id = event.get("realmId")
if auth_code:
session_manager = Oauth2SessionManager(**state)
at = session_manager.get_access_tokens(auth_code)
access_token = session_manager.access_token
print("access_token", access_token)
Its returning {“error”:“invalid_grant”} It could be due to different session_manager objects??
I looked through auth.py, with Oauth1SessionManager we can retrive previous session but I dont see similar option for Oauth2SessionManager.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Access Token Refresh Request, returns Invalid_Grant? - Help - Intuit
As my experienced with this, it because refresh token will be valid only 6 hours. So if you haven't refresh it for more...
Read more >Retrieving OAuth token for SalesForce spoke returns error ...
Retrieving OAuth token for SalesForce spoke returns error "invalid_grant, user hasn't approved this consumer" when target is SalesForce sub-production ...
Read more >How to interpret and resolve the "Invalid Grant" error for ...
THE "INVALID GRANT" ERROR MAY BE RETURNED FOR THE FOLLOWING REASONS The user has revoked your access. The refresh token has not been...
Read more >Using Refresh Token Exception { "error" : "invalid_grant" }
The reason of the "Invalid grant" error may be due to the refresh token not ... an invalidated refresh token, an invalid_grant error...
Read more >Google OAuth “invalid_grant” nightmare — and how to fix it
Based on the error description of the OAuth2 spec, the error message would be returned in cases where the tokens were malformed, incomplete...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cstarner Finally done, need to set session_manager.company_id=realm_id before accessing get_access_token as I was not initializing Quickbook client object.
any suggestions on this? please guide as I am stuck on this.