---
name: "Net::Twitter::Role::AppAuth"
section: "3pm"
platform: "linux"
package: "libnet-twitter-perl"
version: "4.01043-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::Twitter::Role::AppAuth"
---

# Net::Twitter::Role::AppAuth(3pm)

OAuth2 Application Only Authentication

## NAME

Net::Twitter::Role::AppAuth - OAuth2 Application Only Authentication

## VERSION

version 4.01043

## SYNOPSIS

```
  use Net::Twitter;
  my $nt = Net::Twitter->new(
      traits          => ['API::RESTv1_1', 'AppAuth'],
      consumer_key    => "YOUR-CONSUMER-KEY",
      consumer_secret => "YOUR-CONSUMER-SECRET",
  );
  $nt->request_token;
  my $tweets = $nt->user_timeline({ screen_name => 'Twitter' });
```

## DESCRIPTION

Net::Twitter::Role::OAuth is a Net::Twitter role that provides OAuth authentication instead of the default Basic Authentication.

Note that this client only works with APIs that are compatible to OAuth authentication.

## METHODS

- authorized

  True if the client has an access\_token. This does not check the validity of the access token, so requests may fail if it is invalid.

- request\_access\_token

  Request an access token. Returns the token as well as saving it in the object.

- access\_token

  Get or set the access token.

- invalidate\_token

  Invalidates and clears the access\_token.

  Note: There seems to be a Twitter bug preventing this from working---perhaps a documentation bug. E.g., see: \<https://twittercommunity.com/t/revoke-an-access-token-programmatically-always-getting-a-403-forbidden/1902\>
