@edcademy/imgur-auth

1.0.1 • Public • Published

Steps to use this snippet

  1. Run requestAccessToken function either by importing it from this utility or using the window.requestAccessToken in your browser console passing your clientId you obtained from imgur to it.
    It will redirect user to the imgur and authenticate them.
window.requestAccessToken(myClientId);
  1. Upon finishing authentication, imgur will redirect users back to your application. please make sure you have correct redirectUrl set in the imgur configs. Go to this link: (https://imgur.com/account/settings/apps)[https://imgur.com/account/settings/apps] and click on edit beneath the redirect column. set your redirect url to something like: http://localhost:3000/oauth-callback
  2. import OAuthCallback from this package and mount it on the endpoint you've set in the previous step. The following snippet is for the url in previous step:
<Route path="/oauth-callback" exact element={<OAuthCallback />} />
  1. (Optional) You can pass callbacks to OAuthCallback to navigate user away upon finishing authentication:
<Route
  path="/oauth-callback"
  exact
  element={
    <OAuthCallback onAuthenticationSucceed={() => history.replace('/')} />
  }
/>

Readme

Keywords

none

Package Sidebar

Install

npm i @edcademy/imgur-auth

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

2.61 kB

Total Files

4

Last publish

Collaborators

  • eddie_cooro