In project Landing page, click on Create New Account --> Set same account which was configured earlier .
Redirected to Landing page rather providing any validation message
If you login using first email xyz@gmail.com. So it is logged in. So your browser is synced with this gmail account now.
Now, you are going to Create New Account for new email like abc@gmail.com. After clicking, it will go to "Landing Page" again and showing xyz@gmail.com. Because your browser is already synced with first logged in account xyz@gmail.com.
You need to logout after adding new account for removing browser sync.
private GoogleAuthorizationCodeFlow authFlow;
HttpServletResponse response;
GoogleAuthorizationCodeRequestUrl url = authFlow.newAuthorizationUrl();
String redirectURL = url.setRedirectUri(CALLBACK_URI).setAccessType("offline").build();
response.sendRedirect(redirectURL);
Is there any other way to always ask google permission window?
I have fixed the issue adding 'setApprovalPrompt("force")' in url.
String redirectURL = url.setRedirectUri(CALLBACK_URI).setAccessType("offline").setApprovalPrompt("force").build();
I have go through GoogleAuthorizationCodeRequestUrl class documentation. There I have got an option of setting approval prompt.
i) null --> By default
ii) auto --> request to auto-approval
iii) force - to force the approval UI to show.
/**
* Sets the approval prompt behavior ({@code "auto"} to request auto-approval or {@code "force"}
* to force the approval UI to show) or {@code null} for the default behavior of {@code "auto"}.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public GoogleAuthorizationCodeRequestUrl setApprovalPrompt(String approvalPrompt) {
this.approvalPrompt = approvalPrompt;
return this;
}