Class AuthService

The services that handles authentication.

Hierarchy

Constructors

Properties

authProxyUrl?: URL

The URL to the proxy server to use only for authentication.

userId?: string

The id of the authenticated user (if any).

Methods

  • Login to twitter as guest.

    Returns Promise<string>

    A new guest key.

    Example

    import { Rettiwt } from 'rettiwt-api';

    // Creating a new Rettiwt instance
    const rettiwt = new Rettiwt();

    // Logging in an getting a new guest key
    rettiwt.auth.guest()
    .then(guestKey => {
    // Use the guest key
    ...
    })
    .catch(err => {
    console.log(err);
    });
  • Login to twitter using account credentials.

    Parameters

    • email: string

      The email id associated with the Twitter account.

    • userName: string

      The username associated with the Twitter account.

    • password: string

      The password to the Twitter account.

    Returns Promise<string>

    The API_KEY for the Twitter account.

    Example

    import { Rettiwt } from 'rettiwt-api';

    // Creating a new Rettiwt instance
    const rettiwt = new Rettiwt();

    // Logging in an getting the API_KEY
    rettiwt.auth.login("email@domain.com", "username", "password")
    .then(apiKey => {
    // Use the API_KEY
    ...
    })
    .catch(err => {
    console.log(err);
    });

    Remarks

    Interchanging email and userName works too.

  • Makes an HTTP request according to the given parameters.

    Type Parameters

    • T

      The type of the returned response data.

    Parameters

    Returns Promise<T>

    The raw data response received.

    Example

    Fetching the raw details of a user with username 'user1'

    import { FetcherService, EResourceType } from 'rettiwt-api';

    // Creating a new FetcherService instance using the given 'API_KEY'
    const fetcher = new FetcherService({ apiKey: API_KEY });

    // Fetching the details of the User with username 'user1'
    fetcher.request(EResourceType.USER_DETAILS_BY_USERNAME, { id: 'user1' })
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    })
  • Decodes the encoded cookie string.

    Parameters

    • encodedCookies: string

      The encoded cookie string to decode.

    Returns string

    The decoded cookie string.

  • Encodes the given cookie string.

    Parameters

    • cookieString: string

      The cookie string to encode.

    Returns string

    The encoded cookie string.

  • Gets the user's id from the given API key.

    Parameters

    • apiKey: string

      The API key.

    Returns string

    The user id associated with the API key.

Generated using TypeDoc