summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2022-05-29 14:01:37 -0600
committerEduardo Chappa <chappa@washington.edu>2022-05-29 14:01:37 -0600
commit8d79159bae5cd24020ca37de062575c5fd6682f4 (patch)
tree40b0725e2f7dd116ea9e4b40ffd5f48f66a81643
parent284e66afac6e335d1aa6e268b31176d59e61e85c (diff)
downloadalpine-8d79159bae5cd24020ca37de062575c5fd6682f4.tar.xz
* Improve the interface when users try to login using xoauth2 in Gmail.
Users will be told to get a client-id and client-secret only if they do not have a client-id and client-secret that is equal to the default. If they have another client-id and client-secret that will be offered instead, and the message to get one will disappear.
-rw-r--r--alpine/imap.c47
-rw-r--r--alpine/xoauth2conf.c28
-rw-r--r--pith/pine.hlp2
3 files changed, 51 insertions, 26 deletions
diff --git a/alpine/imap.c b/alpine/imap.c
index 3b3efcbd..460908ba 100644
--- a/alpine/imap.c
+++ b/alpine/imap.c
@@ -143,7 +143,7 @@ cache_method_message(STORE_S *in_store)
{
#ifdef LOCAL_PASSWD_CACHE
if(cache_method_was_setup(ps_global->pinerc)){
- so_puts(in_store, _("</P><P> Once you have authorized Alpine, you will be asked if you want to preserve the Refresh Token and Access Code. If you do "));
+ so_puts(in_store, _("</P><P> Once you have authorized Alpine, Alpine will ask you if you want to preserve the Refresh Token and Access Code. If you do "));
so_puts(in_store, _("not wish to repeat this process again, answer \'Y\'es. If you did this process quickly, your connection to the server will still be "));
so_puts(in_store, _("alive at the end of this process, and your connection will proceed from there."));
}
@@ -409,7 +409,7 @@ oauth2_set_device_info(OAUTH2_S *oa2, char *method)
cache_method_message(in_store);
- so_puts(in_store, _(" </P><P>If you do not wish to proceed, cancel at any time by pressing 'E' to exit"));
+ so_puts(in_store, _(" </P><P>If you do not wish to proceed, cancel at any time by pressing 'E' to exit."));
so_puts(in_store, _("</P></HTML>"));
so_seek(in_store, 0L, 0);
@@ -554,42 +554,41 @@ oauth2_get_access_code(unsigned char *url, char *method, OAUTH2_S *oauth2, int *
sprintf(tmp, _("<P>Alpine is attempting to log you into your %s account, using the %s method."), oauth2->name, method),
so_puts(in_store, tmp);
- if(strucmp((char *) oauth2->name, (char *) GMAIL_NAME) == 0){
+ if(strucmp((char *) oauth2->name, (char *) GMAIL_NAME) == 0 && strstr(url, (char *) GMAIL_ID) != NULL){
so_puts(in_store, _(" If this is your first time setting up this type of authentication, please follow the steps below. "));
- so_puts(in_store, _("</P><P> First you must register Alpine with Google and create a client-id and client-secret. If you already did that, then you can skip to the authorization step, and continue with the process outlined below."));
+ so_puts(in_store, _("</P><P> First you must register Alpine with Google and create a client-id and client-secret.</P>"));
so_puts(in_store, _("<UL> "));
so_puts(in_store, _("<LI>First, login to <A HREF=\"https://console.developers.google.com\">https://console.developers.google.com</A> "));
so_puts(in_store, _("and create a project. The name of the project is not important."));
so_puts(in_store, _("<LI> Go to the OAuth Consent Screen and make your app INTERNAL, if your account is a G-Suite account, or EXTERNAL if it is a personal gmail.com account."));
- so_puts(in_store, _("<LI> This will take you to several screens where you must input the required information. You can always use your email address fror developer and contact information. Do not add scopes when you get to the scopes screen and add your email address to the screen to add Test Users."));
+ so_puts(in_store, _("<LI> This will take you to several screens where you must input the required information. You can always use your email address for developer and contact information. Do not add scopes when you get to the scopes screen and add your email address to the screen to add Test Users."));
so_puts(in_store, _("<LI> Create OAUTH Credentials."));
so_puts(in_store, _("</UL> "));
so_puts(in_store, _("<P> As a result of this process, you will get a client-id and a client-secret."));
- so_puts(in_store, _(" Exit this screen, and from Alpine's Main Screen press S U to save these values permanently."));
- so_puts(in_store, _(" Then retry login into Gmail's server, skip these steps, and continue with the steps below."));
+ so_puts(in_store, _(" Exit this screen, and from Alpine's Main Screen press S U to save these values permanently,"));
+ so_puts(in_store, _(" then retry login into Gmail's server."));
so_puts(in_store, _(" More detailed and up to date information on how to configure Alpine for Gmail can be found at the following <A href=\"https://alpine.x10host.com/alpine/alpine-info/misc/RegisteringAlpineinGmail.html\">link</A>."));
- so_puts(in_store, _("</P><P> Cancelling this process will lead to an error in authentication that can be ignored."));
- so_puts(in_store, _("</P><P> If you completed these steps successfully, you are ready to move to the second part, where you will authorize Gmail to give access to Alpine to access your email."));
}
+ else{
+ so_puts(in_store, _("</P><P>In order to authorize Alpine to access your email, Alpine needs to open the following URL:"));
+ so_puts(in_store,"</P><P>");
+ sprintf(tmp_20k_buf, _("<A HREF=\"%s\">%s</A>"), url, url);
+ so_puts(in_store, tmp_20k_buf);
- so_puts(in_store, _("</P><P>In order to authorize Alpine to access your email, Alpine needs to open the following URL:"));
- so_puts(in_store,"</P><P>");
- sprintf(tmp_20k_buf, _("<A HREF=\"%s\">%s</A>"), url, url);
- so_puts(in_store, tmp_20k_buf);
-
- so_puts(in_store, _("</P><P> Alpine will try to use your URL Viewers setting to find a browser to open this URL."));
- sprintf(tmp, _(" When you open this link, you will be sent to %s's servers to complete this process."), oauth2->name);
- so_puts(in_store, tmp);
- so_puts(in_store, _(" Alternatively, you can copy and paste the previous link and open it with the browser of your choice."));
+ so_puts(in_store, _("</P><P> Alpine will try to use your URL Viewers setting to find a browser to open this URL."));
+ sprintf(tmp, _(" When you open this link, you will be sent to %s's servers to complete this process."), oauth2->name);
+ so_puts(in_store, tmp);
+ so_puts(in_store, _(" Alternatively, you can copy and paste the previous link and open it with the browser of your choice."));
- so_puts(in_store, _("</P><P> After you open the previous link, you will be asked to authenticate and later to authorize access to Alpine. "));
- so_puts(in_store, _(" At the end of this process, you will be given an access code or redirected to a web page."));
- so_puts(in_store, _(" If you see a code, copy it and then press 'C', and enter the code at the prompt."));
- so_puts(in_store, _(" If you do not see a code, copy the url of the page you were redirected to and again press 'C' and copy and paste it into the prompt. "));
+ so_puts(in_store, _("</P><P> After you open the previous link, you will be asked to authenticate and later to authorize access to Alpine. "));
+ so_puts(in_store, _(" At the end of this process, you will be given an access code or redirected to a web page."));
+ so_puts(in_store, _(" If you see a code, copy it and then press 'C', and enter the code at the prompt."));
+ so_puts(in_store, _(" If you do not see a code, copy the url of the page you were redirected to and again press 'C' and copy and paste it into the prompt. "));
- cache_method_message(in_store);
+ cache_method_message(in_store);
+ }
- so_puts(in_store, _(" If you do not wish to proceed, cancel by pressing 'E' to exit"));
+ so_puts(in_store, _("</P><P> If you do not wish to proceed, cancel by pressing 'E' to exit."));
so_puts(in_store, _("</P></BODY></HTML>"));
so_seek(in_store, 0L, 0);
diff --git a/alpine/xoauth2conf.c b/alpine/xoauth2conf.c
index 34db4b10..33d99bae 100644
--- a/alpine/xoauth2conf.c
+++ b/alpine/xoauth2conf.c
@@ -179,7 +179,33 @@ xoauth_info_choice(XOAUTH2_INFO_S **xinfo, char *user)
int i, n, rv;
char *extra;
- dprint((9, "xoauth2_info_choice()"));
+ dprint((9, "xoauth_info_choice()"));
+
+ for(i = 0; xinfo && xinfo[i]; i++);
+ if(i == 0) return NULL;
+
+ if(strucmp((char *) xinfo[0]->name, (char *) GMAIL_NAME) == 0){
+ for(i = 0; xinfo && xinfo[i] && strcmp(xinfo[i]->client_id, (char *) GMAIL_ID) != 0; i++);
+ if(!xinfo || xinfo[i] != NULL){
+ int j, offset = 0;
+ XOAUTH2_INFO_S *x;
+
+ for(j = 0; xinfo[j] != NULL; j++){
+ if(j == i){
+ offset++;
+ continue;
+ }
+ x = xinfo[j] ? copy_xoauth2_info(xinfo[j]) : NULL;
+ free_xoauth2_info(&xinfo[j - offset]);
+ xinfo[j - offset] = x;
+ }
+ xinfo[j - offset] = NULL;
+ for(i = 0; xinfo && xinfo[i]; i++);
+ }
+ }
+
+ if(i == 1) return copy_xoauth2_info(xinfo[0]);
+
if(!ps_global->ttyo){
char *s;
char prompt[1024];
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 1c9b3662..5460eca7 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 645 2022-05-16 21:21:27
+Alpine Commit 646 2022-05-29 14:01:33
============= h_news =================
<HTML>
<HEAD>