Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:37:56+00:00 2026-06-11T00:37:56+00:00

I tried a simple if statement to avoid having to run the code below

  • 0

I tried a simple if statement to avoid having to run the code below on every pageload, but the second part with dropbox_authStatus === 1 is not triggered although alert("authStatus: "+dropbox_authStatus); tells me that dropbox_authStatus is 1. What’s wrong with my code?

$('document').ready(function() {

dropbox_authStatus = localStorage.getItem('dropbox_authstatus');
alert("authstatus: "+dropbox_authStatus);

if(!dropbox_authStatus) {
    localStorage.setItem('dropbox_authstatus',1);   
    //initialization
    var client = new Dropbox.Client({
        key: "hm4c58qp6rpysot", secret: "w7cdx6o8p2hyubj"
    });
    alert("initialized");
    //preset driver to the dropbox page
    client.authDriver(new Dropbox.Drivers.Redirect());
    //authentication
    client.authenticate(function(error, client) {
        if (error) {
            return showError(error);  // Something went wrong.
        }
    });
} else if (dropbox_authStatus === 1) {
    localStorage.setItem('dropbox_authstatus',2);   
    //initialization
    var client = new Dropbox.Client({
        key: "hm4c58qp6rpysot", secret: "w7cdx6o8p2hyubj"
    });
    alert("continued");
    //preset driver to the dropbox page
    client.authDriver(new Dropbox.Drivers.Redirect());
    //authentication
    client.authenticate(function(error, client) {
        if (error) {
            return showError(error);  // Something went wrong.
        }
        client.getUserInfo(function(error, userInfo) {
            if (error) {
                return showError(error);  // Something went wrong.
            }

            alert("hello: "+userInfo.name);

        });
    });
    //Save Dropbox credentials
    localStorage.setItem('dropbox_auth', JSON.stringify(client.credentials()));
    alert("credentials saved:"+JSON.stringify(client.credentials()));
}
});

Thanks in advance! The code inside the if-statements mainly belongs to the dropbox.js library hosted on github: https://github.com/dropbox/dropbox-js/blob/master/doc/getting_started.md

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:37:58+00:00Added an answer on June 11, 2026 at 12:37 am

    Answer derived from comments on original question

    I’m just guessing, but if the log seems correct, but the condition isn’t met, maybe dropbox_authStatus is a string instead of a number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i tried to run compile and execute this statement in a simple c
I tried to make a simple contact form via HTML and PHP but the
I have tried to create a simple controller/model (based on the samples code of
I have an Exec SQL Task that runs a simple select statement but is
I'm having trouble finding a simple statement to skip the duplicates for this recursive
I am having trouble with a simple DELETE statement in SQL with unexpected results
I have a very simple update statement: UPDATE W SET state='thing' WHERE state NOT
I'm trying to do a simple if statement but one of the string contains
I have a simple SQL statement. Select distinct value from tablename where value not
I am having trouble writing a simple if statement in a BMC Bladelogic NSH

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.