/** * do process authorization * * @param array $options Authorization options */ public AccessToken authenticate(AuthorizationCode options) { string authenticate_url = null; authenticate_url = _client.request_client(_client.secure) + "://" + _client.host + _client.path + "/" + _client.api_version + "/oauth/token/"; _accesstoken = new AccessToken(); return _accesstoken.getAccessToken(authenticate_url, options); }
/** * Get authorization code and setToken * if process is done successfully, return true else return false * @return boolean */ public bool get_token_from_request() { string authcode = HttpContext.Current.Request.QueryString["code"]; if (authcode != null) { auth_code = authcode; AuthorizationCode code = new AuthorizationCode(); code.client_id = this.client_id; code.client_secret = this.client_secret; code.code = this.auth_code; code.grant_type = "authorization_code"; code.redirect_uri = this.redirect_uri; auth_result = new AccessToken(); this._auth = new Auth(this); auth_result = _auth.authenticate(code); this.setToken(auth_result); return true; } else { return false; } }
// Todo: Searialize type T to Json private string SerializeJson(AuthorizationCode obj) { return(JsonConvert.SerializeObject(obj)); }
// Todo: Searialize type T to Json private string SerializeJson(AuthorizationCode obj) { return JsonConvert.SerializeObject(obj); }
public AccessToken getAccessToken(string url ,AuthorizationCode authCode) { restClient = new RestClient(url, HttpVerb.POST, SerializeJson(authCode), "", ""); AccessToken accessTokenObj = DeserializeJson(restClient.MakeRequest()); return accessTokenObj; }