EtsyOAuth1Authentication is a simple library which allows you to easily perform the first OAuth Authentication step in Etsys current API (v2)
- Built on the .Net Standard library for use in old and new .Net
- Can be added as a service in the DI framework in .NET Core
- Simple and easy to use
Got to https://www.etsy.com and create and account.
Whilst logged in with your etsy account, browse to https://www.etsy.com/developers/ Press the 'Register as a developer' button on the left
Press the 'Create a New App' button Configure you app to meet your current needs (this can be changed afterwards)
Once the app has been created you will be given a KEYSTRING and SHAREDSECRET You use these for authenticating your app against Etsy's OAuth service and to recieve temporary tokens and a URL to call to ask the for permission to add your app to the users Etsy account.
Install the package from NuGet
dotnet add package EtsyOAuth1Authentication --version 1.0.0
var serviceProvider = new ServiceCollection()
.AddEtsyOAuthScoped("KEYSTRING", "SHAREDSECRET") // Scoped version
.AddEtsyOAuthTransient("KEYSTRING", "SHAREDSECRET") // Transient version
.AddEtsyOAuthSingleton("KEYSTRING", "SHAREDSECRET") // Singleton version
.BuildServiceProvider();
var etsyOauth = serviceProvider.GetService<EtsyOauth>();
string tempAccessToken = "";
string tempAccessSecret = "";
string confirmUrl = etsyOauth.GetConfirmUrlWithTempTokens(
out tempAccessToken,
out tempAccessSecret,
new List<ScopesEnum> { ScopesEnum.listings_r, ScopesEnum.transactions_r },
"CALLBACKURL(OPTIONAL)");
Scopes are documented on the Etsy developer portal https://www.etsy.com/developers/documentation/getting_started/oauth#section_permission_scopes
Send your App to the confirm URL (OPTIONAL: pass a callback url) and you will be asked to verify the apps access to the etsy store of the current logged in user, or it will ask the user to login. Once access has been verified, the user will be given a Verification code on screen. Or if you passed a callback URL then Etsy will send that verification code to your callback URL for you to store for the next step
Now that you should have the following data
- TempAccessToken
- TempSecretToken
- VerficationCode
With these, you can call the following method which will give you the permenant access Token and Secret
string permAccessToken = "";
string permAccessSecret = "";
oAuth.ObtainTokenCredentials(tempAccessToken,
tempAccessSecret,
verifyCode,
out permAccessToken,
out permAccessSecret);
Store these tokens in a secure location as they are the keys to your or your users etsy data (Scopes dependant of course)