Can you emulate auth calls for a specific user

Viewed 40

To implement the other calls authorizations/applyToken and customers/user/inquiryUserInfo in code on my server-side, can I generate a authCode from sample Mini Program and then use the same authCode manually in server-code code in debug mode for other calls. Will it work? And what is the expiry time for new generated authCode?

1 Answers

You can indeed. The method above is quite a painful process of course. I would suggest rather you get the userID from your mini-program, then when you want to generate an authCode on the backend you supply your user-id to the applyAuthCode call, and then you will be able to continuously generate an authCode specific to you user on your server without relying on the front-end. (Note, this is possible on the sandbox dev environment only)

The applyToken call isn’t idempotent, so you can only make that request to exchange your authCode once.

The access token is long lived, so the inquiryUserInfo call can be made without worrying about the token expiring.

Related