Skip to content

Commit a76aa34

Browse files
add auth
1 parent cd2473d commit a76aa34

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

wechaty-puppet-hostie/IO/Github/Wechaty/PuppetHostie/PuppetHostie.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,13 +775,26 @@ private function _startGrpcClient() {
775775

776776
// update
777777
// \Grpc\ChannelCredentials::createSsl();
778-
$metadata = array(
779-
'authorization' => 'Wechaty ' . ($this->_puppetOptions ? $this->_puppetOptions->token : ""),
778+
$token = array(
779+
"token_type" => "Wechaty",
780+
"access_token" => $this->_puppetOptions ? $this->_puppetOptions->token : "",
780781
);
781-
Logger::DEBUG($metadata);
782+
$updateMetadata =
783+
function ($metadata,
784+
$authUri = null,
785+
$client = null) use ($token) {
786+
$metadataCopy = $metadata;
787+
$metadataCopy["authorization"] =
788+
[sprintf('%s %s',
789+
$token['token_type'],
790+
$token['access_token'])];
791+
792+
return $metadataCopy;
793+
};
794+
Logger::DEBUG($updateMetadata);
782795
$this->_grpcClient = new \Wechaty\PuppetClient($hostname, [
783796
'credentials' => \Grpc\ChannelCredentials::createInsecure(),
784-
'update_metadata' => $metadata,
797+
'update_metadata' => $updateMetadata,
785798
]);
786799
return $this->_grpcClient;
787800
}

0 commit comments

Comments
 (0)