Skip to contents

The li_oauth function facilitates OAuth 2.0 authentication for interacting with the LinkedIn API. It uses the authorization code flow to generate an OAuth token.

Usage

li_oauth()

Value

An OAuth token object (of class httr2_token) that can be used to authenticate subsequent API requests to LinkedIn.

Details

The function performs the following steps:

  1. Calls li_client() to initialize the OAuth client using the LinkedIn client ID and secret (stored as environment variables: LI_CLIENT_ID and LI_CLIENT_SECRET).

  2. Constructs the authorization URL with the required state, scope, and client details.

  3. Executes the authorization code flow using httr2::oauth_flow_auth_code, which:

    • Prompts the user to allow access.

    • Supports redirection to http://localhost:1444/ to complete the authorization process.

    • Specifies required LinkedIn permissions (scope): email, openid, profile, and w_member_social.

Examples

if (FALSE) { # \dontrun{
# Perform LinkedIn OAuth authentication and save the token
token <- li_oauth()

# Use the token for authenticated API requests
token
} # }