mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-06 03:50:08 +02:00
configurable redirect-url
This commit is contained in:
parent
68d42c3488
commit
a5907d6e0a
3 changed files with 14 additions and 6 deletions
|
@ -358,7 +358,8 @@ int main(int argc, char ** argv)
|
||||||
printf("oauth2: set addr first.\n");
|
printf("oauth2: set addr first.\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char* oauth2_url = dc_get_oauth2_url(context, addr);
|
char* oauth2_url = dc_get_oauth2_url(context, addr,
|
||||||
|
"urn:ietf:wg:oauth:2.0:oob");
|
||||||
if (oauth2_url==NULL) {
|
if (oauth2_url==NULL) {
|
||||||
printf("OAuth2 not available for %s.\n", addr);
|
printf("OAuth2 not available for %s.\n", addr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,19 @@ static int is_expired(dc_context_t* context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* dc_get_oauth2_url(dc_context_t* context, const char* addr)
|
char* dc_get_oauth2_url(dc_context_t* context, const char* addr,
|
||||||
|
const char* redirect)
|
||||||
{
|
{
|
||||||
#define CLIENT_ID "959970109878-t6pl4k9fmsdvfnobae862urapdmhfvbe.apps.googleusercontent.com"
|
// it's fine to add the "secret" to "offline" apps source code,
|
||||||
|
// "In this context, the client secret is obviously not treated as a secret."
|
||||||
|
// https://developers.google.com/identity/protocols/OAuth2
|
||||||
#define CLIENT_SECRET "g2f_Gc1YUJ-fWjnTkdsuk4Xo"
|
#define CLIENT_SECRET "g2f_Gc1YUJ-fWjnTkdsuk4Xo"
|
||||||
#define AUTH_REDIRECT "urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob"
|
#define CLIENT_ID "959970109878-t6pl4k9fmsdvfnobae862urapdmhfvbe.apps.googleusercontent.com"
|
||||||
#define AUTH_SCOPE "https%3A%2F%2Fmail.google.com%2F%20email"
|
#define AUTH_SCOPE "https%3A%2F%2Fmail.google.com%2F%20email"
|
||||||
|
|
||||||
char* oauth2_url = NULL;
|
char* oauth2_url = NULL;
|
||||||
char* addr_normalized = NULL;
|
char* addr_normalized = NULL;
|
||||||
|
char* redirect_urlencoded = NULL;
|
||||||
const char* domain = NULL;
|
const char* domain = NULL;
|
||||||
|
|
||||||
addr_normalized = dc_addr_normalize(addr);
|
addr_normalized = dc_addr_normalize(addr);
|
||||||
|
@ -59,6 +63,8 @@ char* dc_get_oauth2_url(dc_context_t* context, const char* addr)
|
||||||
}
|
}
|
||||||
domain++;
|
domain++;
|
||||||
|
|
||||||
|
redirect_urlencoded = dc_urlencode(redirect);
|
||||||
|
|
||||||
if (strcasecmp(domain, "gmail.com")==0
|
if (strcasecmp(domain, "gmail.com")==0
|
||||||
|| strcasecmp(domain, "googlemail.com")==0) {
|
|| strcasecmp(domain, "googlemail.com")==0) {
|
||||||
oauth2_url = dc_mprintf("https://accounts.google.com/o/oauth2/auth"
|
oauth2_url = dc_mprintf("https://accounts.google.com/o/oauth2/auth"
|
||||||
|
@ -67,11 +73,12 @@ char* dc_get_oauth2_url(dc_context_t* context, const char* addr)
|
||||||
"&response_type=code"
|
"&response_type=code"
|
||||||
"&scope=%s"
|
"&scope=%s"
|
||||||
"&access_type=offline",
|
"&access_type=offline",
|
||||||
CLIENT_ID, AUTH_REDIRECT, AUTH_SCOPE);
|
CLIENT_ID, redirect_urlencoded, AUTH_SCOPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
free(addr_normalized);
|
free(addr_normalized);
|
||||||
|
free(redirect_urlencoded);
|
||||||
return oauth2_url;
|
return oauth2_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ char* dc_get_blobdir (const dc_context_t*);
|
||||||
int dc_set_config (dc_context_t*, const char* key, const char* value);
|
int dc_set_config (dc_context_t*, const char* key, const char* value);
|
||||||
char* dc_get_config (dc_context_t*, const char* key);
|
char* dc_get_config (dc_context_t*, const char* key);
|
||||||
char* dc_get_info (dc_context_t*);
|
char* dc_get_info (dc_context_t*);
|
||||||
char* dc_get_oauth2_url (dc_context_t*, const char* addr);
|
char* dc_get_oauth2_url (dc_context_t*, const char* addr, const char* redirect);
|
||||||
char* dc_get_version_str (void);
|
char* dc_get_version_str (void);
|
||||||
void dc_openssl_init_not_required (void);
|
void dc_openssl_init_not_required (void);
|
||||||
void dc_no_compound_msgs (void); // deprecated
|
void dc_no_compound_msgs (void); // deprecated
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue