question

rolystar avatar image
0 Likes"
rolystar asked ·

OAuth autohirzation code grant token valid for one instance?

Hi, I am trying to automate the process to generate tokens in C# using the OAuth Library provided. Currently in order to get this token the user has to agree to terms and conditions and take the code generated and exchange it for an authorization code. This process needs human interaction, is there a way to use the library to get that code back after the user accepts the terms and conditions. We are developing this for our own business for our own account so it would be generated for one user which is us. Also, is the access token received only valid for one instance of the app running? What I noticed, if I stop the app the previous code and refresh token will not work once I spin up a new instance of the app even tho the first thing it does is regenerate the previous token. Just need an official confirmation on this one if the code granted after the approval of terms and conditions is only valid per instance of app running or its possible to use that to regenerate new tokens after the app is stopped and started again. Kind regards, Roland
tokenoauth2tokensoauth library
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
ericday avatar image
0 Likes"
ericday answered ·
If you view the repo on github ( https://github.com/eBay/ebay-oauth-csharp-client) and look in the tests you'll find some end to end tests using the chromedriver and selenium that could potentially be used to automate the process of getting a code and turning it into a token. I started down that path but encountered a problem with the chromedriver not working in 64 bit. I've not troubleshot further since the refresh token is currently meeting my needs. I've noticed the code is very short lived. You need to very quickly use it to get a token. Tokens seem to be good for about a day. When I start developing each day, my app almost always has to start with using the refresh token to get another access token. Rather than using the code to get new tokens you should use the refresh token. Something like this: public string GetTokenFromRefresh() { var response = _oauthService.GetAccessToken(OAuthEnvironment.PRODUCTION, _refreshToken, _scopes); return response.AccessToken.Token; }
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.