Forum Discussion

seizo's avatar
seizo
Helpful | Level 6
8 years ago
Solved

How to find the present-log-in-account in the redirect_uri

I have a question about /oauth2/authorize end point.

Now I'm developing an Android app.
The app sends a request to /oauth2/authorize end point. (response_type=token)
I could confirm that the endpoint redirects the data to a certain web-page that I had set in my app-settings (redirect_uri).


At this moment, if I had already logged in to Dropbox service with the account "AAA@gmail.com"
I can get token for the account "AAA@gmail.com" in the redirect_uri.

Here is my question below .....

If I have several Dropbox accounts,
for example ...
"AAA@gmail.com"
"BBB@gmail.com"
"CCC@gmail.com"
how can I know the the token in the redirect_uri is for?

Are there any ways to send the present-log-in-account-id to the redirect_uri.


How to find the present-log-in-account in the redirect_uri

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    When Dropbox sends the user back to the redirect URI specified by your app, it will include the 'account_id' for the account that authorized the app, along with the other parameters, on the URL fragment. You can find the documentation for all of the pieces of information returned here:

     

    https://www.dropbox.com/developers/documentation/http/documentation#oauth2-authorize

     

    Note that since this occurs client-side, you can't strictly trust these values for authentication purposes, so you should then call /2/users/get_current_account using that access token to verify the account ID, if that's what you need it for:

     

    https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account

    • seizo's avatar
      seizo
      Helpful | Level 6

      Greg, thank you for the advice.

       

      As you said there is account_id in the URL fragment.
      It is like this below.
      "dbid%32221111%%%%%%%sssspppp"

      But the user who are facing the redirect-page needs to know the current account,
      because he/she has to decide to change the account or not at this moment.


      So I think that /oauth2/authorize end point has to return log-in id
      like "aaaa@dropbox.com" rather than account_id like "dbid%32221111%%%%%%%sssspppp",
      to specify the user the account that /oauth2/authorize have permitted to access.

       

      :)

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff
        The /oauth2/authorize web page itself shows the user which account they're currently logged in to in the drop down in the upper right corner of the page. They can also switch which account they're logged in to by signing out and in there, before authorizing the app.
  • Kiang M59's avatar
    Kiang M59
    Explorer | Level 4
    ใช้งานง่ายและรวดเร็ว

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,945 PostsLatest Activity: 4 hours ago
351 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!