Returns model representing the slack user, you will need the scopes:
identity.basic,identity.email

@param string $code
@return OAuthUser
556789
public function getSlackUserFromOAuthCode($code)
    {
        $params = [
            'client_id' => $this->slackClientId,
            'client_secret' => $this->slackSecret,
            'code' => $code
        ];

        $request = $this->client->request('POST', 'https://slack.com/api/oauth.access', ['form_params' => $params]);

        $data = json_decode($request->getBody()->getContents(), true);

        return new OAuthUser(
            empty($data['user']['id']) ? null : $data['user']['id'],
            empty($data['user']['email']) ? null : $data['user']['email']
        );
    }
101588
public function getUserInfoByCode($code) {
		$data = $this->getData('/sns/oauth2/access_token', [
			'appid' => $this->app->appid,
			'secret' => $this->app->secret,
			'grant_type' => 'authorization_code',
			'code' => $code,
		]);

		$user = [];
		if($this->errcode == 0) {
			$user['openid'] = $data['openid'];
			if($data['scope'] == 'snsapi_userinfo') {
				$data = $this->getData('/sns/userinfo', [
					'access_token' => $data['access_token'],
					'openid' => $user['openid'],
					'lang' => \Yii::$app->language,
				]);
				if($this->errcode == 0) {
					$user = $data;
				}
			}
		}

		return $user;
	}
252443
public function findByActivationCode($code)
	{
		if ( ! $code)
		{
			throw new \InvalidArgumentException("No activation code passed.");
		}

		$model = $this->createModel();

		$result = $model->where('activation_code', '=', $code)->get();

		if (($count = $result->count()) > 1)
		{
			throw new \RuntimeException("Found [$count] users with the same activation code.");
		}

		 $user = $result->find();

		if ( !$user->loaded() )
		{
			throw new UserNotFoundException("A user was not found with the given activation code.");
		}

		return $user;
	}
1163322
public function getAuthorizationCode($code)
	{
		// auth model
		$authorizationCode = \Components\Developer\Models\Authorizationcode::oneByCode($code);

		// fetch by code
		if (!$authorizationCode->get('id'))
		{
			return false;
		}

		// get the application's client id
		$application = \Components\Developer\Models\Application::oneOrFail($authorizationCode->get('application_id'));
		$authorizationCode->set('client_id', $application->get('client_id'));

		// format expires to unix timestamp for authorization code grant type
		$authorizationCode->set('expires', with(new Date($authorizationCode->get('expires')))->toUnix());

		// return code
		return $authorizationCode->toArray();
	}
436122
static function getUniShip($code)
    {
        static::isValid($code);

        switch ($code) {
            case static::EBP :
                return 'CC';
            case static::GBP :
                return 'FF';
            case static::EP :
            case static::SHD :
            case static::FDF :
                return null;
            case static::BP :
            default:
                return 'AA';
        }
    }
1047808
public function authenticateByCode($provider, string $code)
    {
        $provider_user = $provider->user();

        /** @var \Railken\Amethyst\Repositories\UserRepository */
        $repository = $this->manager->getRepository();

        $user = $repository->findOneByEmail($provider_user->getEmail());

        if (!$user) {
            $result = $this->manager->create([
                'name'     => $provider_user->getNickname() ? $provider_user->getNickname() : $provider_user->getName(),
                'role'     => 'user',
                'password' => str_random(32),
                'email'    => $provider_user->getEmail(),
            ]);

            if (!$result->ok()) {
                return $this->response(['errors' => $result->getSimpleErrors()], Response::HTTP_BAD_REQUEST);
            }

            $user = $result->getResource();
        }

        $token = Container::getInstance()->make(\Laravel\Passport\PersonalAccessTokenFactory::class)->make(
            $user->getKey(),
            'login',
            []
        );

        return $this->response([
            'token_type'   => 'Bearer',
            'expires_in'   => 0,
            'access_token' => $token->accessToken,
        ], Response::HTTP_OK);
    }
15779
public function getAuthorizationCode($code)
    {
        $stmt = $this->db->prepare(sprintf('SELECT * from %s where authorization_code = :code', $this->config['code_table']));
        $stmt->execute(compact('code'));

        if ($code = $stmt->fetch()) {
            // convert date string back to timestamp
            $code['expires'] = strtotime($code['expires']);
        }

        return $code;
    }
853373
public function requestAccessToken($code)
    {
        $params = array(
            'code' => $code,
            'grant_type' => 'authorization_code',
            'client_id' => $this->_getClientId(),
            'redirect_uri' => $this->_getRedirectUri(),
            'scope' => $this->_getScope()
        );

        return $this->_makeRequest($this->_tokenEndPoint, $params);
    }
75627
public function getCurrency($code = null)
    {
        $code = $code ?: $this->getUserCurrency();

        return Arr::get($this->getCurrencies(), strtoupper($code));
    }
771301
public function authenticate($code = null)
    {
        if (null === $code) {
            if (isset($_GET['code'])) {
                $code = $_GET['code'];
            }
        }

        $url = 'https://oauth.vk.com/access_token?' . http_build_query(array(
                'client_id' => $this->getClientId(),
                'client_secret' => $this->getClientSecret(),
                'code' => $code,
                'redirect_uri' => $this->getRedirectUri(),
            ));

        $token = $this->curl($url);
        $decodedToken = json_decode($token, true);
        $decodedToken['created'] = time(); // add access token created unix timestamp to array

        $this->setAccessToken($decodedToken);

        return $this;
    }
955721
public function getAccessToken($code = null) {
        if ($this->debug) { $start = microtime(true); }
        if ($code) {
            // todo get access_token via authorization_code request
            $params['client_id']     = $this->getClientID();
            $params['client_secret'] = $this->getClientSecret();
            $params['redirect_uri']  = $this->getRedirectUri();
            $params['grant_type']    = 'authorization_code';
            $params['scope']         = '';
            $params['state']         = '';
            $params['code']          = $code;
            $access_token = (array) json_decode($this->makeRequest($this->getTokenURL(), $params));
        } else {
            if ($this->accessToken) {
                return $this->accessToken;
            } else {
                $session = $this->getSession();
                // either user session signed, or app signed
                if (isset($session['access_token'])) {
                    $access_token = $session['access_token'];
                } else {
                    // No success! Defaults to
                    $access_token = $this->getClientID();
                }
            }
        }
        if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; }
        return $access_token;
    }
841416
protected function UserGetGroupIdByCode($code)
    {
        $rsGroups = CGroup::GetList(($by = 'c_sort'), ($order = 'desc'), [
            'STRING_ID' => $code,
        ]);
        if ($ob = $rsGroups->Fetch()) {
            return $ob['ID'];
        } else {
            return null;
        }
    }
114434
private function getAccessToken($code)
    {
        $this->logger->debug('Get Access Token.');
        $this->initRequest();
        $token_url = $this->fcBaseUrl.'token';
        $post_data = [
            "grant_type"    => "authorization_code",
            "redirect_uri"  => $this->callbackUrl,
            "client_id"     => $this->clientId,
            "client_secret" => $this->clientSecret,
            "code"          => $code,
        ];
        $this->logger->debug('POST Data to FranceConnect.');
        $this->setPostFields($post_data);
        $response = \Unirest\Request::post($token_url);
        
        // check status code
        if ($response->code != Response::HTTP_OK) {
            $result_array = $response->body;
            $description = array_key_exists(
                "error_description",
                $result_array
            ) ? $result_array["error_description"] : '';
            $this->logger->error(
                $result_array["error"].$description
            );
            throw new Exception("FranceConnectError".$response->code." msg = ".$response->raw_body);
        }
        
        $result_array = $response->body;
        $id_token = $result_array['id_token'];
        $this->session->set(static::ID_TOKEN_HINT, $id_token);
        $all_part = explode(".", $id_token);
        $payload = json_decode(base64_decode($all_part[1]), true);
        
        // check nonce parameter
        if ($payload['nonce'] != $this->session->get(static::OPENID_SESSION_NONCE)) {
            $this->logger->error('The value of the parameter NONCE is not equal to the one which is expected');
            throw new SecurityException("The nonce parameter is invalid");
        }
        // verify the signature of jwt
        $this->logger->debug('Check JWT signature.');
        $jws = SimpleJWS::load($id_token);
        if (!$jws->verify($this->clientSecret)) {
            $this->logger->error('The signature of the JWT is not valid.');
            throw new SecurityException("JWS is invalid");
        }
        
        $this->session->remove(static::OPENID_SESSION_NONCE);
        
        return $result_array['access_token'];
    }
960803
public static function authentication($code = '')
    {
        if (empty($code)) {
            return false;
        }

        // authorize
        $authorize = self::authorize($code);

        if (!$authorize) {
            return false;
        }

        if (isset($authorize['error'])) {
            return $authorize;
        }

        // return infos
        return self::info($authorize['access_token']);
    }
220481
public function requestAccessToken($code, $requestType)
    {
        switch ($requestType) {
            case 'pin':
                $grantType = 'pin';
                $type = 'pin';
                break;
            case 'code':
            default:
                $grantType = 'authorization_code';
                $type = 'code';
        }

        try {
            $response = $this->httpClient->post(
                self::ACCESS_TOKEN_ENDPOINT,
                [
                    'client_id' => $this->clientId,
                    'client_secret' => $this->clientSecret,
                    'grant_type' => $grantType,
                    $type => $code,
                ]
            );

            $responseBody = json_decode($response->getBody(), true);
        } catch (\Exception $e) {
            throw new AuthException('Request for access token failed: ' . $e->getMessage(), $e->getCode());
        }

        $responseBody['created_at'] = time();
        $this->setAccessToken($responseBody);

        $this->sign();

        return $responseBody;
    }
899009
public function getHeader($code)
    {
        if (isset($this->headers[$code])) {
            return $this->headers[$code];
        }

        return null;
    }
857227
public function getAccessToken($code, $state = null, $redirectUri = null)
    {
        // No state provided
        // Should probably be
        // handled explicitly
        if (!is_null($state)) {
            //Decode the State
            $state = $this->decodeState($state);

            //CSRF Token
            $csrfToken = $state['csrfToken'];

            //Set the URL State
            $this->urlState = $state['urlState'];

            //Validate CSRF Token
            $this->validateCSRFToken($csrfToken);
        }

        //Fetch Access Token
        $accessToken = $this->getOAuth2Client()->getAccessToken($code, $redirectUri);

        //Make and return the model
        return new AccessToken($accessToken);
    }