cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Where should I locate the 'startOAuth2Authentication'?

Where should I locate the 'startOAuth2Authentication'?

Dolphin_2018
Explorer | Level 4
Go to solution

Hi,

 

Question 1:

 

I'm totally new to Android Studio and I have to add a DropBox (SDK V2) files loading method to an existing project. As I understood I have to add the following line to my code:

 

Auth.startOAuth2Authentication(UserActivity.this, getString(R.string.app_key));

as shows here in line 36:

 

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/c...

 

But where should I add it in MY code?

 

I tried to add the line to the place in my code that looks most logic to me, to the file "MainActivity.Java", here:

 

@TargetApi(23)
@Override
protected void onCreate(Bundle savedInstanceState) 
{
super.onCreate(savedInstanceState);
Auth.startOAuth2Authentication(UserActivity.this, getString(R.string.app_key));
  .
  .
  .
  .
}

but I'm getting an error: "Cannot resolve symbol 'Auth'".

So I tried to add the following to the top of this file as shown in the "Android" example project:

 

import com.dropbox.core.android.Auth;
import com.dropbox.core.examples.android.internal.OpenWithActivity;
import com.dropbox.core.v2.users.FullAccount;

and I'm getting the error: "Cannot resolve symbol 'core'"

 

I tried "Clear Project", "Rebuild Project" and also I tried "Invalidate Caches/Restart..." but the error still there.

 

What should I do in order to remove this error? and anyway what are all this "import" lines? are these names of a .jar files? where should I find them? and put them? or are these modules inside the DropBox SDK?

 

Question 2:

 

Later I have to add this to my code:

  

SharedPreferences prefs = getSharedPreferences("??????", MODE_PRIVATE);
String accessToken = prefs.getString("??????", null);

if (accessToken == null) {
    accessToken = Auth.getOAuth2Token();
}

 But what should be the first parameter in:

 

getSharedPreferences(...)

and in:

 

getString(...)

methods? should it be the name of my DropBox account's App? what is it?

 

I also tried to call only:

 

accessToken = Auth.getOAuth2Token();

but I'm getting 

accessToken = null...

Why ? does this method need the APP_KEY and the SECRET_KEY ?

 

Please advice,

Thanks ...

 

11 Replies 11

Greg-DB
Dropbox Staff
Go to solution
I'll follow up there.

Dolphin_2018
Explorer | Level 4
Go to solution

Thanks!

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Dolphin_2018 Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?