Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Komsomol opened this issue May 1, 2018 · 1 comment

Comments

@Komsomol
Copy link

Komsomol commented May 1, 2018

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:

  • user clicks share
  • logs into twitter/facebook
  • image is shared
  • user goes back to start
  • user clicks share
  • user has to log in again to share

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
Copy link

hdmiimdh commented Jul 12, 2019

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 :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants