oauth-io / oauth-js

OAuth that just works ! This is the JavaScript SDK for OAuth.io
https://oauth.io
796 stars 196 forks source link

clearCache and cache:false doesn't seem to clear cache to force re-login #99

Open Komsomol opened 6 years ago

Komsomol commented 6 years ago

I am using OAuth-js to share images on Facebook and Twitter.

However, I am running into an issue where forcing clearCache and cache: false doesn't seem to force users to re-login.

Ideally this is the flow am after:

See code below. I force both but the credientails are still retained once the user authenticates. Is this correct behaviour or have i placed the calls in the wrong place? (Code is exact to my working version but stripped of app specific messaging to the UI)

Thanks.


// initialize OAuth
OAuth.initialize('XXXXXXXXXXX');

// clear any previous logins 
OAuth.clearCache();

// logining into twitter
OAuth.popup("twitter", {cache:false}).then(function(twitter) {
    console.log("twitter", twitter);

    var formData = new FormData();

    // add the source of the image (needs to be raw binary with type added)
    formData.append('media', Utils.getBlob(image));

    // upload image to get media id
    twitter.post('https://upload.twitter.com/1.1/media/upload.json',{
        data: formData,
        cache:false,
        processData: false,
        contentType: false
    }).done(function(uploadResult){
        console.log("uploaded media asset to twitter ",uploadResult);
        // use media ID to post to user wall 
        twitter.post('/1.1/statuses/update.json',{
            data:{
                status:message,
                media_ids:uploadResult.media_id_string
            }
        }).done(function(postResult){

            console.log("posted to twitter ", postResult);
            if(postResult.id){
                console.log("successful submission to twitter");
            }else{
                app.showErrorPost();
            }

        }).fail(function(postFail){
            console.log("post to twitter fail ",postFail.responseText);
        });

    }).fail(function(uploadfail){
        console.log("failed to upload media asset ",uploadfail.responseText);
    });

}).done(function(loginResult){
    console.log("successful twitter auth ",loginResult);
}).fail(function(loginFail){
    // if the user denies log in
    console.log("failed twitter auth ",loginFail.responseText);
});
hdmiimdh commented 5 years ago

any update to this issue, these options do not work for me as well, in case cached credentials are no longer valid you'll be given the error without any option to relogin, that's extremely annoying, we're thinking to move to other solutions instead :(