Fix error creation and warning
[claws.git] / src / oauth2.h
blob51eb60dcf4b1d784490fb5f554593ab3231166b2
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2020-2022 the Claws Mail team
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.
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.
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/>.
20 #ifdef HAVE_CONFIG_H
21 #include "claws-features.h"
22 #endif
24 #ifdef USE_OAUTH2
26 #include <glib.h>
28 #include "socket.h"
29 #include "passwordstore.h"
30 #include "smtp.h"
31 #include "prefs_account.h"
33 #define OAUTH2BUFSIZE 8192
35 typedef enum
37 OA2_BASE_URL,
38 OA2_CLIENT_ID,
39 OA2_CLIENT_SECRET,
40 OA2_REDIRECT_URI,
41 OA2_AUTH_RESOURCE,
42 OA2_ACCESS_RESOURCE,
43 OA2_REFRESH_RESOURCE,
44 OA2_RESPONSE_TYPE,
45 OA2_SCOPE_FOR_AUTH,
46 OA2_GRANT_TYPE_ACCESS,
47 OA2_GRANT_TYPE_REFRESH,
48 OA2_TENANT,
49 OA2_STATE,
50 OA2_ACCESS_TYPE,
51 OA2_SCOPE_FOR_ACCESS,
52 OA2_RESPONSE_MODE,
53 OA2_HEADER_AUTH_BASIC
54 } Oauth2Params;
56 typedef enum
58 OAUTH2AUTH_NONE,
59 OAUTH2AUTH_GOOGLE,
60 OAUTH2AUTH_OUTLOOK,
61 OAUTH2AUTH_EXCHANGE,
62 OAUTH2AUTH_YAHOO,
63 OAUTH2AUTH_LAST = OAUTH2AUTH_YAHOO
64 } Oauth2Service;
66 typedef struct _OAUTH2Data OAUTH2Data;
67 struct _OAUTH2Data
69 gchar *refresh_token;
70 gchar *access_token;
71 gint expiry;
72 gchar *expiry_str;
73 gchar *custom_client_id;
74 gchar *custom_client_secret;
77 gint oauth2_init (OAUTH2Data *OAUTH2Data);
78 gint oauth2_check_passwds (PrefsAccount *ac_prefs);
79 gint oauth2_obtain_tokens (Oauth2Service provider, OAUTH2Data *OAUTH2Data, const gchar *authcode);
80 gint oauth2_authorisation_url (Oauth2Service provider, gchar **url, const gchar *custom_client_id);
81 gint oauth2_use_refresh_token (Oauth2Service provider, OAUTH2Data *OAUTH2Data);
82 guchar* oauth2_decode(const gchar *in);
83 void oauth2_encode(const gchar *in);
85 #endif /* USE_GNUTLS */