1 /* 2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client 3 * Copyright (C) 2020 the Claws Mail team 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifdef HAVE_CONFIG_H 21 #include "claws-features.h" 22 #endif 23 24 #include <glib.h> 25 26 #include "socket.h" 27 #include "passwordstore.h" 28 #include "smtp.h" 29 #include "prefs_account.h" 30 31 #define OAUTH2BUFSIZE 8192 32 33 typedef enum 34 { 35 OA2_BASE_URL, 36 OA2_CLIENT_ID, 37 OA2_CLIENT_SECRET, 38 OA2_REDIRECT_URI, 39 OA2_AUTH_RESOURCE, 40 OA2_ACCESS_RESOURCE, 41 OA2_REFRESH_RESOURCE, 42 OA2_RESPONSE_TYPE, 43 OA2_SCOPE_FOR_AUTH, 44 OA2_GRANT_TYPE_ACCESS, 45 OA2_GRANT_TYPE_REFRESH, 46 OA2_TENANT, 47 OA2_STATE, 48 OA2_ACCESS_TYPE, 49 OA2_SCOPE_FOR_ACCESS, 50 OA2_RESPONSE_MODE, 51 OA2_HEADER_AUTH_BASIC 52 } Oauth2Params; 53 54 typedef enum 55 { 56 OAUTH2AUTH_NONE, 57 OAUTH2AUTH_GOOGLE, 58 OAUTH2AUTH_OUTLOOK, 59 OAUTH2AUTH_EXCHANGE, 60 OAUTH2AUTH_YAHOO, 61 OAUTH2AUTH_LAST = OAUTH2AUTH_YAHOO 62 } Oauth2Service; 63 64 typedef struct _OAUTH2Data OAUTH2Data; 65 struct _OAUTH2Data 66 { 67 gchar *refresh_token; 68 gchar *access_token; 69 gint expiry; 70 gchar *expiry_str; 71 gchar *custom_client_id; 72 gchar *custom_client_secret; 73 }; 74 75 gint oauth2_init (OAUTH2Data *OAUTH2Data); 76 gint oauth2_check_passwds (PrefsAccount *ac_prefs); 77 gint oauth2_obtain_tokens (Oauth2Service provider, OAUTH2Data *OAUTH2Data, const gchar *authcode); 78 gint oauth2_authorisation_url (Oauth2Service provider, gchar **url, const gchar *custom_client_id); 79 gint oauth2_use_refresh_token (Oauth2Service provider, OAUTH2Data *OAUTH2Data); 80 guchar* oauth2_decode(const gchar *in); 81 void oauth2_encode(const gchar *in); 82