title: How do I post to Twitter using Unity3D with Authorization INSTEAD of PIN?
body: <p>I have a game completely in JavaScript. It sucks because I have to alter my C# plugins by shoving them into my plugin folder, and activate the commands inside the C# script using JavaScript. </p>
  
  <p>I have downloaded "Let's Tweet in Unity" from the Asset store, and it comes with 2 Scripts. One script Defines "Twitter" and all the functions it can represent. The other is "Demo" which basically activates the functions within the Twitter Class. </p>
  
  <p>So I altered "Demo" to my liking. But in this "Demo" it seems to want me to go through this process of Requesting a Token from twitter, which takes me to their website which gives me a Pin Number, then I have to go back to my app, paste the pin number, then write whatever I want to write, and only then I can post it.</p>
  
  <p>I was wondering what methods I need to take to change this to that one method that just allows "such and such app" to have authentication to your Twitter account.</p>
  
  <p>Currently the only commands I have are</p>
  
  <pre><code>GetRequestToken
  
  GetAccessToken
  
  PostToTwitter
  </code></pre>
  
  <p>And here is the script below:</p>
  
  <pre><code>using Twitter;
  using UnityEngine;
  
  public class TwitterTrigger : MonoBehaviour
  {
      // You need to register your game or application in Twitter to get cosumer key and secret.
      // Go to this page for registration: http://dev.twitter.com/apps/new
      public string CONSUMER_KEY;
      public string CONSUMER_SECRET;
  
  // You need to save access token and secret for later use.
  // You can keep using them whenever you need to access the user's Twitter account. 
  // They will be always valid until the user revokes the access to your application.
  const string PLAYER_PREFS_TWITTER_USER_ID           = "TwitterUserID";
  const string PLAYER_PREFS_TWITTER_USER_SCREEN_NAME  = "TwitterUserScreenName";
  const string PLAYER_PREFS_TWITTER_USER_TOKEN        = "TwitterUserToken";
  const string PLAYER_PREFS_TWITTER_USER_TOKEN_SECRET = "TwitterUserTokenSecret";
  
  Twitter.RequestTokenResponse m_RequestTokenResponse;
  Twitter.AccessTokenResponse m_AccessTokenResponse;
  
  string m_PIN = "Please enter your PIN here.";
  string m_Tweet = "Please enter your tweet here.";
  
  // Use this for initialization
  private void Start()
  {
      LoadTwitterUserInfo();
  
  }
  
  // Update is called once per frame
  private void Update()
  {
  }
  
  public void Post() {
      /*post
      StartCoroutine(API.PostTweet("This is a twitter api test.",
                                  CONSUMER_KEY,
                                  CONSUMER_SECRET,
                                  m_AccessTokenResponse,
                                  OnPostTweet));
                                  */
  
      StartCoroutine(Twitter.API.PostTweet("This is a twitter api test.",
                                           CONSUMER_KEY,
                                           CONSUMER_SECRET,
                                           m_AccessTokenResponse,
                                           new Twitter.PostTweetCallback(this.OnPostTweet)));
  }
  public void GetAccessToken() {
      StartCoroutine(Twitter.API.GetAccessToken(CONSUMER_KEY, CONSUMER_SECRET, m_RequestTokenResponse.Token, m_PIN,
                                                new Twitter.AccessTokenCallback(this.OnAccessTokenCallback)));
  }
  public void GetRequestToken() {
      StartCoroutine(Twitter.API.GetRequestToken(CONSUMER_KEY, CONSUMER_SECRET,
                                                 new Twitter.RequestTokenCallback(this.OnRequestTokenCallback)));
  
  }
  private void LoadTwitterUserInfo()
  {
      m_AccessTokenResponse = new AccessTokenResponse();
  
      m_AccessTokenResponse.UserId = PlayerPrefs.GetString(PLAYER_PREFS_TWITTER_USER_ID);
      m_AccessTokenResponse.ScreenName = PlayerPrefs.GetString(PLAYER_PREFS_TWITTER_USER_SCREEN_NAME);
      m_AccessTokenResponse.Token = PlayerPrefs.GetString(PLAYER_PREFS_TWITTER_USER_TOKEN);
      m_AccessTokenResponse.TokenSecret = PlayerPrefs.GetString(PLAYER_PREFS_TWITTER_USER_TOKEN_SECRET);
  
      if (!string.IsNullOrEmpty(m_AccessTokenResponse.Token) &amp;&amp;
          !string.IsNullOrEmpty(m_AccessTokenResponse.ScreenName) &amp;&amp;
          !string.IsNullOrEmpty(m_AccessTokenResponse.Token) &amp;&amp;
          !string.IsNullOrEmpty(m_AccessTokenResponse.TokenSecret))
      {
          string log = "LoadTwitterUserInfo - succeeded";
          log += "\n    UserId : " + m_AccessTokenResponse.UserId;
          log += "\n    ScreenName : " + m_AccessTokenResponse.ScreenName;
          log += "\n    Token : " + m_AccessTokenResponse.Token;
          log += "\n    TokenSecret : " + m_AccessTokenResponse.TokenSecret;
          Debug.Log(log);
      }
  }
  
  private void OnRequestTokenCallback(bool success, RequestTokenResponse response)
  {
      if (success)
      {
          string log = "OnRequestTokenCallback - succeeded";
          log += "\n    Token : " + response.Token;
          log += "\n    TokenSecret : " + response.TokenSecret;
          print(log);
  
          m_RequestTokenResponse = response;
  
          //API.OpenAuthorizationPage(response.Token);
          //GetAccessToken();
          //Post();
      }
      else
      {
          print("OnRequestTokenCallback - failed.");
      }
  }
  
  private void OnAccessTokenCallback(bool success, AccessTokenResponse response)
  {
      if (success)
      {
          string log = "OnAccessTokenCallback - succeeded";
          log += "\n    UserId : " + response.UserId;
          log += "\n    ScreenName : " + response.ScreenName;
          log += "\n    Token : " + response.Token;
          log += "\n    TokenSecret : " + response.TokenSecret;
          print(log);
  
          m_AccessTokenResponse = response;
  
          PlayerPrefs.SetString(PLAYER_PREFS_TWITTER_USER_ID, response.UserId);
          PlayerPrefs.SetString(PLAYER_PREFS_TWITTER_USER_SCREEN_NAME, response.ScreenName);
          PlayerPrefs.SetString(PLAYER_PREFS_TWITTER_USER_TOKEN, response.Token);
          PlayerPrefs.SetString(PLAYER_PREFS_TWITTER_USER_TOKEN_SECRET, response.TokenSecret);
  
          //Post();
      }
      else
      {
          print("OnAccessTokenCallback - failed.");
      }
  }
  
  private void OnPostTweet(bool success)
  {
      print("OnPostTweet - " + (success ? "succedded." : "failed."));
  }
  }
  </code></pre>