调用Medium API OAuth授权接口报错:请求无法被识别
Let’s break down the likely issues causing this error and how to fix them step by step:
Fix URL formatting errors
Your request URL uses HTML-encoded&instead of plain&as parameter separators, plus unnecessary trailing spaces after some parameter values (likeclient_id=xxxx). These will break Medium’s request parsing logic.
Replace&with&and strip all extra spaces. Your corrected URL should look like this:https://medium.com/m/oauth/authorize?client_id=xxxx&scope=publish_post&state=CA&response_type=code&redirect_uri=mywebsiteurlCorrect the scope parameter format
Medium’s API uses snake_case for scope names, not camelCase. You usedpublishPost, but the valid scope for publishing posts ispublish_post. Using the wrong naming convention here will trigger a request validation error.Verify redirect_uri matches exactly
Double-check that theredirect_uriin your request is 100% identical to the one configured in your Medium developer application settings. Even tiny differences (like missinghttps://, a trailing slash, or a typo in the domain) will cause this error.Use a valid random state value
WhileCAmight not break things immediately, thestateparameter should be a unique, random string to prevent CSRF attacks. Using a static value isn’t best practice, though this is less likely to be the direct cause of your current error.
After applying these fixes, retry the authorization request—this should resolve the "We didn’t understand your request" issue.
内容的提问来源于stack exchange,提问作者umdeveloper

