Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set 'refresh_token' value #167

Open
4 of 6 tasks
moggiex opened this issue Apr 8, 2024 · 2 comments
Open
4 of 6 tasks

Unable to set 'refresh_token' value #167

moggiex opened this issue Apr 8, 2024 · 2 comments
Assignees

Comments

@moggiex
Copy link

moggiex commented Apr 8, 2024

  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?

Describe the bug
This might be me doing this incorrectly, however I could not see a way of setting the value of the 'refresh_token' anywhere, so when the token expired, I had no way of requesting a new one.

In the readme file its says we need "Keep in mind that you need the 'refresh_token' value set.", but gives no example or explanation

Then discovered I could set this as an object below and pass that to eBay.OAuth2.setCredentials() which works, but is causing a ts error as setCredentials(authToken: AuthToken | string): void; is expecting a string and I cannot see another way of setting the value of refresh_token

Code

const authToken = {
			access_token: token,
			refresh_token: refresh_token,
		};
		eBay.OAuth2.setCredentials(authToken as any);

So either I'm working around the issue by sending an object to setCredentials() and breaking the ts, have missed a way of setting the value of 'refresh_token' by other means or setCredentials() needs to allow a second param or an object to set the value of 'refresh_token' I think?

Output

expected data

Would you like to work on this issue?

  • Yes
  • No
  • Maybe
@dantio
Copy link
Collaborator

dantio commented Apr 8, 2024

@moggiex
Thank you for raising this issue,

What you showed is the correct way to set the access token and refresh token. setCredentials() also accepts AuthToken-Type:

setCredentials({
        refresh_token: refresh_token,
        expires_in: 7200,
        refresh_token_expires_in: 47304000,
        token_type: 'User Access Token',
        access_token: token
      });

That should avoid the TS errors.

However, I see we need some type improvements here. expires_in, token_type and refresh_token_expires_in can be optional. This fields are not used (yet?).
mintUserAccessToken() should return a correct Type. I'll work on this. Thank you!

@dantio
Copy link
Collaborator

dantio commented Apr 19, 2024

@moggiex
Do you solve your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants