ericcj/amz_sp_api

How to change refresh_token

LksNuns opened this issue ยท 11 comments

Hi, I have an application, and I want to fetch data from Amazon for each user. I started to read the amazon documentation and this library.

Every time the user authorizes my app, we received a code from this user to generate an access_token and refresh_token through LWA.
Looking into the code I found

refresh_token: config.refresh_token,

I tried creating a new AmzSpApi::SpConfiguration.new to use in AmzSpApi::SpApiClient.new(config), but then all attributes come with nil.

There is a way to only change the refresh_token?

Sorry about opening this issue. I read more about the code of this gem, and figure out a way to do this.

Rather than all of us code diving, it would be great if you (or someone) could put newcomers to how to do that. That is step 1 of connecting to the SP-API and it is not totally clear - at least to me - how to do that. If it is in this code it would be nice to highlight it (or maybe even put it on the Readme)

@LksNuns how did you do it?

@philsmy @jakemcallister @LksNuns
Hello
Would love to know more about that please ๐Ÿ™๐Ÿผ

How to handle the first step? Does the gem handle the OAuth flow? How does my code know which Amazon vendor it is handling?

Thanks so much in advance

@philsmy instead of asking others to do work, why don't you dive in and submit a pull request?

@tarekrahme There is some information here that might be helpful - #17.

Once you save it, the refresh token does not change. The client requests new access_token as needed.

This is how i'm instantiating API clients for each account in my application: https://www.blandersoft.com/short/sp-api/

Thanks so much @blairanderson @mendywoly
So just to confirm, I have to handle OAuth flow first (not handled by this gem).

The OAuth flow will allow me to get the refresh token which I then use to make queries to the Amz SP API.

Correct? Am I missing something?

@tarekrahme see if this helps you at all. #43

Once again thanks a lot @blairanderson @mendywoly I really appreciate it
๐Ÿ™๐Ÿผ๐Ÿ™๐Ÿผ๐Ÿ™๐Ÿผ
Hopefully soon I can start contributing to the gem ๐Ÿ™‚