static fromAuthCode ({
    code = requiredArg('code'),
    userAgent = isBrowser ? global.navigator.userAgent : requiredArg('userAgent'),
    clientId = requiredArg('clientId'),
    clientSecret,
    redirectUri = requiredArg('redirectUri'),
    endpointDomain = 'reddit.com'
  }) {
    return this.prototype.credentialedClientRequest.call({
      userAgent,
      clientId,
      clientSecret,
      // Use `this.prototype.rawRequest` function to allow for custom `rawRequest` method usage in subclasses.
      rawRequest: this.prototype.rawRequest
    }, {
      method: 'post',
      baseUrl: `https://www.${endpointDomain}/`,
      uri: 'api/v1/access_token',
      form: {grant_type: 'authorization_code', code, redirect_uri: redirectUri}
    }).then(response => {
      if (response.error) {
        throw new errors.RequestError(`API Error: ${response.error} - ${response.error_description}`);
      }
      // Use `new this` instead of `new snoowrap` to ensure that subclass instances can be returned
      const requester = new this({userAgent, clientId, clientSecret, ...response});
      requester.config({endpointDomain});
      return requester;
    });
  }
/**
   * @summary Creates a snoowrap requester from an authorization code.
   * @desc An authorization code is the `code` value that appears in the querystring after a user authenticates with reddit and
   is redirected. For more information, see {@link snoowrap.getAuthUrl}.
   *
   * The main use-case for this function is for running snoowrap in a browser. You can generate a URL with
   {@link snoowrap.getAuthUrl} and send the user to that URL, and then use this function to create a requester when
   the user is redirected back with an authorization code.
   * @param {object} options
   * @param {string} options.code The authorization code
   * @param {string} options.userAgent A unique description of what your app does. This argument is not necessary when snoowrap
   is running in a browser.
   * @param {string} options.clientId The client ID of your app (assigned by reddit). If your code is running clientside in a
   browser, using an "Installed" app type is recommended.
   * @param {string} [options.clientSecret] The client secret of your app. If your app has the "Installed" app type, omit
   this parameter.
   * @param {string} options.redirectUri The redirect URI that is configured for the reddit app.
   * @param {string} [options.endpointDomain='reddit.com'] The endpoint domain that the returned requester should be configured
   to use. If the user is authenticating on reddit.com (as opposed to some other site with a reddit-like API), you can omit this
   value.
   * @returns {Promise<snoowrap>} A Promise that fulfills with a `snoowrap` instance
   * @example
   *
   * // Get the `code` querystring param (assuming the user was redirected from reddit)
   * var code = new URL(window.location.href).searchParams.get('code');
   *
   * snoowrap.fromAuthCode({
   *   code: code,
   *   userAgent: 'My app',
   *   clientId: 'foobarbazquuux',
   *   redirectUri: 'example.com'
   * }).then(r => {
   *   // Now we have a requester that can access reddit through the user's account
   *   return r.getHot().then(posts => {
   *     // do something with posts from the front page
   *   });
   * })
   */
@summary Creates a snoowrap requester from an authorization code.
@desc An authorization code is the `code` value that appears in the querystring after a user authenticates with reddit and
is redirected. For more information, see  snoowrap.getAuthUrl.

The main use-case for this function is for running snoowrap in a browser. You can generate a URL with
snoowrap.getAuthUrl and send the user to that URL, and then use this function to create a requester when
the user is redirected back with an authorization code.
@param {object} options
@param {string} options.code The authorization code
@param {string} options.userAgent A unique description of what your app does. This argument is not necessary when snoowrap
is running in a browser.
@param {string} options.clientId The client ID of your app (assigned by reddit). If your code is running clientside in a
browser, using an "Installed" app type is recommended.
@param {string} [options.clientSecret] The client secret of your app. If your app has the "Installed" app type, omit
this parameter.
@param {string} options.redirectUri The redirect URI that is configured for the reddit app.
@param {string} [options.endpointDomain='reddit.com'] The endpoint domain that the returned requester should be configured
to use. If the user is authenticating on reddit.com (as opposed to some other site with a reddit-like API), you can omit this
value.
@returns {Promise} A Promise that fulfills with a `snoowrap` instance
@example

Get the `code` querystring param (assuming the user was redirected from reddit)
var code = new URL(window.location.href).searchParams.get('code').


@summary Creates a snoowrap requester from an authorization code . @desc An authorization code is the ` code ` value that appears in the querystring after a user authenticates with reddit and is redirected . For more information see snoowrap . getAuthUrl . The main use - case for this function is for running snoowrap in a browser . You can generate a URL with snoowrap . getAuthUrl and send the user to that URL and then use this function to create a requester when the user is redirected back with an authorization code . @param { object } options @param { string } options . code The authorization code @param { string } options . userAgent A unique description of what your app does . This argument is not necessary when snoowrap is running in a browser . @param { string } options . clientId The client ID of your app ( assigned by reddit ) . If your code is running clientside in a browser using an " Installed " app type is recommended . @param { string } [ options . clientSecret ] The client secret of your app . If your app has the " Installed " app type omit this parameter . @param { string } options . redirectUri The redirect URI that is configured for the reddit app . @param { string } [ options . endpointDomain = ' reddit . com ' ] The endpoint domain that the returned requester should be configured to use . If the user is authenticating on reddit . com ( as opposed to some other site with a reddit - like API ) you can omit this value . @returns { Promise } A Promise that fulfills with a ` snoowrap ` instance @example Get the ` code ` querystring param ( assuming the user was redirected from reddit ) var code = new URL ( window . location . href ) . searchParams . get ( ' code ' ) .
static fromAuthCode ({
    code = requiredArg('code'),
    userAgent = isBrowser ? global.navigator.userAgent : requiredArg('userAgent'),
    clientId = requiredArg('clientId'),
    clientSecret,
    redirectUri = requiredArg('redirectUri'),
    endpointDomain = 'reddit.com'
  }) {
    return this.prototype.credentialedClientRequest.call({
      userAgent,
      clientId,
      clientSecret,
      rawRequest: this.prototype.rawRequest
    }, {
      method: 'post',
      baseUrl: `https://www.${endpointDomain}/`,
      uri: 'api/v1/access_token',
      form: {grant_type: 'authorization_code', code, redirect_uri: redirectUri}
    }).then(response => {
      if (response.error) {
        throw new errors.RequestError(`API Error: ${response.error} - ${response.error_description}`);
      }
      const requester = new this({userAgent, clientId, clientSecret, ...response});
      requester.config({endpointDomain});
      return requester;
    });
  }
static fromAuthCode ( { code = requiredArg ( 'code' ) , userAgent = isBrowser ? global . navigator . userAgent : requiredArg ( 'userAgent' ) , clientId = requiredArg ( 'clientId' ) , clientSecret , redirectUri = requiredArg ( 'redirectUri' ) , endpointDomain = 'reddit.com' } ) { return this . prototype . credentialedClientRequest . call ( { userAgent , clientId , clientSecret , rawRequest : this . prototype . rawRequest } , { method : 'post' , baseUrl : ` ${ endpointDomain } ` , uri : 'api/v1/access_token' , form : { grant_type : 'authorization_code' , code , redirect_uri : redirectUri } } ) . then ( response => { if ( response . error ) { throw new errors . RequestError ( ` ${ response . error } ${ response . error_description } ` ) ; } const requester = new this ( { userAgent , clientId , clientSecret , ... response } ) ; requester . config ( { endpointDomain } ) ; return requester ; } ) ; }
@summary Creates a snoowrap requester from an authorization code.
@summary Creates a snoowrap requester from an authorization code .
// Use `this.prototype.rawRequest` function to allow for custom `rawRequest` method usage in subclasses. // Use `new this` instead of `new snoowrap` to ensure that subclass instances can be returned