//#define GOOGLE_CLIENT_ID "670877175811-sfjbiiambdqg411db9472u13ko89m972.apps.googleusercontent.com"
//#define GOOGLE_CLIENT_SECRET "FHPYeaQnAD2nFEA7yyJac2SS"
-
#define GOOGLE_CLIENT_ID "670877175811-fneddq3cnvgajhalsndlqargbft6tn5j.apps.googleusercontent.com"
#define GOOGLE_CLIENT_SECRET "AIRkuD9jcPEtaHwDZlvW-pwr"
-
#define OAUTH2_TYPE_STR(k) #k
typedef enum {
GOOGLE_OAUTH2_CODE,
+ GOOGLE_OAUTH2_CHECK_STATE,
+
ALL_OAUTH2_TYPE
} oauth2_type_e;
const char *scope;
const char *state;
const char *custom_data;
+ oauth2_type_e auth_type;
+
};
static char *oauth2_list[1024] = {
OAUTH2_TYPE_STR(GOOGLE_OAUTH2_CODE),
+ OAUTH2_TYPE_STR(GOOGLE_OAUTH2_CHECK_STATE)
};
static void _app_destroy_cb(void* this);
static void show_google_auth_output(void* user_data);
static void oauth2_info_button_pressed_cb(void *data, Evas_Object *obj, void *event_info);
static char* get_oauth2_error(oauth2_error_e error);
+static void _oauth2_auth_grant_cb(oauth2_response_h response, void *user_data);
/**
if(!strcmp(enum_text, OAUTH2_TYPE_STR(GOOGLE_OAUTH2_CODE)))
{
+ this->auth_type = GOOGLE_OAUTH2_CODE;
+ start_google_oauth_code(this);
+ }
+ else if(!strcmp(enum_text, OAUTH2_TYPE_STR(GOOGLE_OAUTH2_CHECK_STATE)))
+ {
+ this->auth_type = GOOGLE_OAUTH2_CHECK_STATE;
start_google_oauth_code(this);
}
}
*/
static void start_google_oauth_code(void* data)
{
- DBG("clear_chache_button_pressed_cb");
+ DBG("start_google_oauth_code");
RETM_IF(NULL == data, "data is NULL");
oauth2_view *this = NULL;
ret = oauth2_request_set_response_type(request, OAUTH2_RESPONSE_TYPE_CODE);
RETM_IF(ret != OAUTH2_ERROR_NONE, "oauth2_request_set_response_type error: %s", get_oauth2_error(ret));
- ret = oauth2_request_add_custom_data(request, "c_key", "c_val");
+ ret = oauth2_request_add_custom_data(request, "access_type", "offline");
RETM_IF(ret != OAUTH2_ERROR_NONE, "oauth2_request_add_custom_data error: %s", get_oauth2_error(ret));
+ ret = oauth2_request_add_custom_data(request, "prompt", "consent");
+ RETM_IF(ret != OAUTH2_ERROR_NONE, "oauth2_request_add_custom_data error: %s", get_oauth2_error(ret));
+
+ ret = oauth2_request_set_state(request, "test_state");
+ RETM_IF(ret != OAUTH2_ERROR_NONE, "oauth2_request_set_state error: %s", get_oauth2_error(ret));
+
+
if (mgr && request)
{
this->oauth2_mgr = mgr;
- ret = oauth2_manager_request_token(mgr, request, token_response_cb, this);
- RETM_IF(ret != OAUTH2_ERROR_NONE, "oauth2_manager_request_token error: %s", get_oauth2_error(ret));
+
+ if(this->auth_type == GOOGLE_OAUTH2_CHECK_STATE)
+ {
+ elm_object_disabled_set(this->btn_oauth2_info, true);
+ ret = oauth2_manager_request_authorization_grant(mgr, request, _oauth2_auth_grant_cb, this);
+ DBG("oauth2_manager_request_authorization_grant error: %s", get_oauth2_error(ret));
+ }
+ else if(this->auth_type == GOOGLE_OAUTH2_CODE)
+ {
+ elm_object_disabled_set(this->btn_oauth2_info, false);
+ ret = oauth2_manager_request_token(mgr, request, token_response_cb, this);
+ DBG("oauth2_manager_request_token error: %s", get_oauth2_error(ret));
+ }
+
}
}
+static void _oauth2_auth_grant_cb(oauth2_response_h response, void *user_data)
+{
+ DBG("_oauth2_auth_grant_cb");
+ RETM_IF(NULL == user_data, "data is NULL");
+
+ oauth2_view *this = NULL;
+ this = (oauth2_view*) user_data;
+ RETM_IF(NULL == this, "view is NULL");
+
+ oauth2_error_e result;
+
+
+ char* state = NULL;
+ result = oauth2_response_get_state(response, &state);
+ RETM_IF(result != OAUTH2_ERROR_NONE, "oauth2_response_get_state error: %s", get_oauth2_error(result));
+ RETM_IF(NULL == state, "state NULL!");
+ this->state = state;
+
+ char str[128];
+ snprintf(str, sizeof(str), "%s%s", "state : ", this->state);
+ elm_object_text_set(this->google_desc_obj, str);
+}
+
/**
* @function token_response_cb
* @since_tizen 2.3
RETM_IF(result != OAUTH2_ERROR_NONE, "oauth2_response_get_token_type error: %s", get_oauth2_error(result));
RETM_IF(NULL == token_type, "token_type NULL!");
this->token_type = token_type;
+ DBG("token type : %s", token_type);
char *ref_token = NULL;
result = oauth2_response_get_refresh_token(response, &ref_token);
+ if(result != OAUTH2_ERROR_NONE)
+ {
+ ERR("oauth2_response_get_refresh_token error: %s", get_oauth2_error(result));
+ }
+ if(NULL == ref_token)
+ {
+ ERR("ref_token NULL!");
+ }
RETM_IF(result != OAUTH2_ERROR_NONE, "oauth2_response_get_refresh_token error: %s", get_oauth2_error(result));
RETM_IF(NULL == ref_token, "ref_token NULL!");
this->refresh_token = ref_token;
//RETM_IF(NULL == scope, "scope NULL!");
this->scope = scope;
- char* state = NULL;
- result = oauth2_response_get_state(response, &state);
- //RETM_IF(result != OAUTH2_ERROR_NONE, "oauth2_response_get_state error: %s", get_oauth2_error(result));
- //RETM_IF(NULL == state, "state NULL!");
- this->state = state;
+// char* state = NULL;
+// result = oauth2_response_get_state(response, &state);
+// RETM_IF(result != OAUTH2_ERROR_NONE, "oauth2_response_get_state error: %s", get_oauth2_error(result));
+// RETM_IF(NULL == state, "state NULL!");
+// this->state = state;
char *acc_token = NULL;
result = oauth2_response_get_access_token(response, &acc_token);
RETM_IF(result != OAUTH2_ERROR_NONE, "oauth2_response_get_access_token error: %s", get_oauth2_error(result));
- //RETM_IF(NULL == acc_token, "acc_token NULL!");
+ RETM_IF(NULL == acc_token, "acc_token NULL!");
this->access_token = acc_token;