Google Api, Node.js - invalid_grant Malformed auth code

前端 未结 1 809
春和景丽
春和景丽 2021-01-14 17:53

I\'m trying to use the google api on node.js, but I always have the following error:

invalid_grant
Malformed auth code

By searching on the

相关标签:
1条回答
  • 2021-01-14 18:52

    Here is my case:

    The authorization code in the url hash fragment is being encoded by encodeURIComponent API, so if you pass this code to request the access token. It will throw an error:

    { "error": "invalid_grant", "error_description": "Malformed auth code." }

    So I use decodeURIComponent to decode the authorization code.

    decodeURIComponent('4%2F_QCXwy-PG5Ub_JTiL7ULaCVb6K-Jsv45c7TPqPsG2-sCPYMTseEtqHWcU_ynqWQJB3Vuw5Ad1etoWqNPBaGvGHY')
    

    After decode, the authorization code is:

    "4/_QCXwy-PG5Ub_JTiL7ULaCVb6K-Jsv45c7TPqPsG2-sCPYMTseEtqHWcU_ynqWQJB3Vuw5Ad1etoWqNPBaGvGHY"
    
    0 讨论(0)
提交回复
热议问题