Authenticating to OAuth2 Services lesson(trouble)
<p>I am trying to follow the lesson on <a href="https://developer.android.com/training/id-auth/authenticate.html" rel="nofollow">developer.android.com</a> and I am getting stuck on the 
<code>am.getAuthToken(
            myAccount_, AUTH_TOKEN_TYPE,options,this,new OnTokenAcquired(),new Handler(new OnError()));</code></p>

<p>I don't get what to put in for the myAccount_; Is it accounts that is linked to the account array? <code>Account[] accounts  = accountManager.getAccountsByType("com.google");</code></p>

<p>The token part on <code>class OnTokenAcquired</code> is also gennerating an error saying it isn't a var, should I just make it a global var even though it is suposse to be a constant in the <code>AccountManager.KEY_AUTHTOKEN</code>?</p>

<p><a href="http://code.google.com/apis/tasks/articles/oauth-and-tasks-on-android.html" rel="nofollow">This is the other link for the Authentication lesson</a> and I am getting an error with <code>DIALOG_ACCOUNTS</code>, <code>showDialog(DIALOG_ACCOUNTS)</code> and <code>manager.getAuthToken(account, AUTH_TOKEN_TYPE, null, activity, new AccountManagerCallback&lt;Bundle&gt;()</code> in that tutorioul. I haven't gone much further in it because of the errors I am currently getting. </p>

<p>I don't get why these errors are happening? I assume it is just me not putting in the right vars though.</p>

<p>Any suggestions? </p>

<p>Here is the code I have copied. </p>

<pre><code>public class AccountManagerActivity extends Activity {

AccountManager accountManager = AccountManager.get(this);

Account[] accounts  = accountManager.getAccountsByType("com.google");

String AUTH_TOKEN_TYPE = "Manage your tasks";
String your_api_key;
String your_client_id;
String your_client_secret;
String token;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    URL url = new URL("https://www.googleapis.com/tasks/v1/users/@me/lists?key=" + your_api_key);
    URLConnection conn = (HttpURLConnection) url.openConnection();

    conn.addRequestProperty("client_id", your_client_id);

    conn.addRequestProperty("client_secret", your_client_secret);

    conn.setRequestProperty("Authorization", "OAuth " + token);



    AccountManager am = AccountManager.get(this);
    Bundle options = new Bundle();

    am.invalidateAuthToken(token, AUTH_TOKEN_TYPE);
    am.getAuthToken(
        /*Error here*/ myAccount_,                     // Account retrieved using getAccountsByType()
        AUTH_TOKEN_TYPE,                // Auth scope
        options,                        // Authenticator-specific options
        this,                           // Your activity
        new OnTokenAcquired(),          // Callback called when a token is successfully acquired
        new Handler(new OnError()));    // Callback called if an error occurs
}

}
</code></pre>

<p>And then the OnTokenAcquired class</p>

<pre><code>public class OnTokenAcquired implements AccountManagerCallback&lt;Bundle&gt; {

public void run(AccountManagerFuture&lt;Bundle&gt; result) {
    // TODO Auto-generated method stub
    // Get the result of the operation from the AccountManagerFuture.
    Bundle bundle = result.getResult();

    // The token is a named value in the bundle. The name of the value
    // is stored in the constant AccountManager.KEY_AUTHTOKEN.
  /*Error here*/  Token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
    Intent launch = (Intent) result./*Error here*/get(AccountManager.KEY_INTENT);
    if (launch != null) {
       /*Error here*/ startActivityForResult(launch, 0);
        return;
    }


}

}
</code></pre>
