Domanda

I'm trying to use the dropbox API on my android app, and I don't want to send the user to the authentication page every time he opens the program, just the first time. So I save the token from the first time in a variable called key, and when I initialize the session I use this constractor:

AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys,key);
mDBApi = new DropboxAPI<AndroidAuthSession>(session);
mDBApi.getSession().setOAuth2AccessToken(key);

As you can see I put in the key twice in two different methods just to be sure.
Now according to what i could find on the subject, if I got the key I don't need to authenticate using this function:

mDBApi.getSession().startOAuth2Authentication(MyBroadcastRecActivity.this);

So I erased that line.
After that I send the program to do another task but it doesn't work - it works when I authenticate the user using the function above, but then the user have to confirm it every time, but when I use the key I stored and don't do the authentication the program does nothing.
I have tried every source and answer on the web and there dosen't seem to be anything.
Thanks ahead for your help.

È stato utile?

Soluzione

The way you set the token key is

AccessTokenPair tokens=new AccessTokenPair(token_key,token_seceret);
mDBApi.getSession().setAccessTokenPair(tokens); 

Have a look at their example app DBRoulette.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top