Logg in withand uuth token from the accountmanager on my app
===

I'm trying to change the authentication of my app using oauth from Android's accountmanager. Getting the accounts is fine but then I have to get an auth token and I don't know what I'm supposed to do with it ? I probably have to send it somewhere and store it so the users don't have to logg in each time but I just can't figure that out after viewing loads of tutorials on it :S ...

Here is my code :

    
    public class TestAuthActivity extends Activity {
    	
    	
    	
    	String AUTH_TOKEN_TYPE = "Manage your tasks";//"oauth2:https://www.googleapis.com/auth/tasks"; / "oauth2:https://spreadsheets.google.com/feeds/";
    	Account account;
    	static final int DIALOG_ACCOUNTS = 0;
        AccountManager accountManager;
        Account[] accounts;
        //String token;
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		
    		Bundle options = new Bundle();
    		accountManager = AccountManager.get(this);
    		accounts = accountManager.getAccountsByType("com.google");
    		
    	       setContentView(R.layout.main);			// j'affiche le XML de la page
    	       
    	       if(accounts.length > 1){
    	    	   showDialog(DIALOG_ACCOUNTS);	
    
    	       }else{
    	    	   account = accounts[0];
    	    	   System.out.println(account.name);
    	       }
    	       
    	       accountManager.getAuthToken(account, AUTH_TOKEN_TYPE, options, this, new OnTokenAcquired(), null);
    	}
    
    
    	
    	@Override
    	protected Dialog onCreateDialog(int id) {
    
    		switch (id) {
    	    case DIALOG_ACCOUNTS:
    	
    		AlertDialog.Builder builder = new AlertDialog.Builder(this);
    	      builder.setTitle("Select a Google account");
    	      final int size = accounts.length;
    	      String[] names = new String[size];
    	      for (int i = 0; i < size; i++) {
    	        names[i] = accounts[i].name; // ID of the account
    	      }
    	      builder.setItems(names, new DialogInterface.OnClickListener() {
    	        public void onClick(DialogInterface dialog, int which) {
    	          
    	        	account = accounts[which];
    		    	   System.out.println(account.name);
    	        }
    	      });
    	      return builder.create();
    
    		}
    		
    		return null;
    	}
    	
    	private class OnTokenAcquired implements AccountManagerCallback<Bundle> {
    	    @Override
    	    public void run(AccountManagerFuture<Bundle> result) {
    	        // Get the result of the operation from the AccountManagerFuture.
    	        Bundle bundle;
    			try {
    				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.
    		        String token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
    		        
    		        Intent launch = (Intent) bundle.get(AccountManager.KEY_INTENT);
    		        if (launch != null) {
    		            startActivityForResult(launch, 0);
    		            return;
    		        }
    				
    			} catch (OperationCanceledException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (AuthenticatorException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    	    
    	        
    	    }
    	}
    
    }

