Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function gettoken()
- {
- $dataMeta = $this->db->get_where('app_meta', array('meta_id' => 1))->row();
- $clientId = $dataMeta->meta_client_id;
- $clientSecret = $dataMeta->meta_client_secret;
- $oauthCallback = $dataMeta->meta_auth_callback;
- // Code setelah Callback, bisakh otomatis
- $code = trim($this->input->get('code'));
- $baseEncode = $clientId . ':' . $clientSecret;
- $basicAuth = base64_encode($baseEncode);
- $header = array(
- "Authorization: Basic " . $basicAuth,
- );
- $content = array(
- "code" => $code,
- "grant_type" => "authorization_code",
- "redirect_uri" => $oauthCallback,
- );
- $url = "https://account.accurate.id/oauth/token";
- $opts = array("http" => array(
- "method" => "POST",
- "header" => $header,
- "content" => http_build_query($content),
- "ignore_errors" => true,
- ),
- );
- $context = stream_context_create($opts);
- $response = file_get_contents($url, false, $context);
- $json = json_decode($response);
- $access_token = trim($json->access_token);
- $refresh_token = trim($json->refresh_token);
- return $access_token;
- }
Add Comment
Please, Sign In to add comment