How to get the control back to my app, If user clicks on DENY button in Trello Authorization screen
Asked by Gmanik446:

In our application we are using Trello authentication and authorization flow to get the consent from user. Below is the code sample that we are using for user Trello Authorization.

Trello.authorize({  
type: "redirect",  
name: "Trello for MyApp",  
scope: {  
read: true,  
write: true  
},  
expiration: "never",  
success: authenticationSuccess,  
error: authenticationFailure  
});

function authenticationSuccess() {  
console.log("Authentication success");  
}

function authenticationFailure() {  
console.log("Authentication failed");  
}

Once user chosen an account and login, trello is giving control back to my application by calling success call back method "authenticationSuccess". But If user clicks on "DENY" button in authorization screen, then trello is not giving control back to my application. The failure call back method "authenticationFailure" is not executing. Could you please suggest me, how can I get the control back to my App when user clicks on "DENY" button?


Answers:
author: bentley
body: It looks like this only happens when using *type: "redirect".* Here is an example of using *type: "popup"* : <https://glitch.com/edit/#!/using-trello-js?path=public/example.js>

We'll look into seeing if this is something we can fix. I'll update here when I find out more.

comments: author: bentley
body: ![Screen Shot 2017-07-31 at 10.59.10 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/3823i949852155A404BC1/image-dimensions/391x187?v=v2 "Screen Shot 2017-07-31 at 10.59.10 AM.png")


author: Gmanik446
body: Thank you for the reply. As per [Trello documentation](https://developers.trello.com/v1.0/docs/clientjs), if we set interactive:false, then it doesn't redirect or popup and only uses the stored access token. But in my case, I need to redirect the user.


author: bentley
body: On the initial page-visit you should make the call without *interactive: false* - this will cause them to be redirected. Once they have selected Accept or Deny, they will be redirected back to your page at which point you should make the call again with *interactive: false* . If they did select Deny then at this point in time your *authenticationFailure* will be called.


author: Gmanik446
body: It's not redirecting to our page when user selected Deny. It's simple showing page as shown in below image.

![Token reject.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/5023i6F04633989F6AF1A/image-size/large?v=v2&px=999 "Token reject.PNG")

This is the issue we are facing.


author: bentley
body: [@Gmanik446](/t5/user/viewprofilepage/user-id/1138650) Are you using *type: "popup"* or *type: "redirect"* when you see that?


author: Gmanik446
body: We are using type:redirect. You can find the sample code in my question description.


author: bentley
body: [@Gmanik446](/t5/user/viewprofilepage/user-id/1138650) I've put together an example project of how to use *type: redirect* here: <https://glitch.com/edit/#!/discreet-minibus?path=public/example.js:6:0.>

You will want to call *Trello.authorize* with *interactive: false* on page load to see if the user has authorized or not. If they have no authorized, you will want to call *Trello.authorize* again but this time with *interactive: true* so that they are redirected.


author: bentley
body: @Gmanik44 When a user is not logged in and selects *Deny* when prompted to authorize with an app, we intentionally only show the error message, "Token request rejected." We intentionally do not redirect because then that route would be an open redirect for non-logged-in Trello users and could be abused to phish accounts.


author: Gmanik446
body: [@bentley](/t5/user/viewprofilepage/user-id/313402)Thank you for reply. Is there any way or work around to redirect user when users selects Deny?


author: bentley
body: [@Gmanik446](/t5/user/viewprofilepage/user-id/1138650) For non-logged-in users, no. For logged-in users, control is returned to you.