-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Provider] Garmin: oauth_verifier in params in getRequestAuthorization #4
Comments
Hi, this is not a bug as this library does not offer a Garmin provider class (yet). |
@matamalabs btw where does the method in your code snippet get the |
The Garmin Connect API is private so I'm not available to provide you. You can register on https://developer.garmin.com/gc-developer-program/health-api/ |
Actually, I do: public function getRequestAuthorization(RequestInterface $request, AccessToken|null $token = null):RequestInterface{
$token ??= $this->storage->getAccessToken($this->name);
if($token->isExpired()){
throw new InvalidAccessTokenException;
}
$query = $request->getUri()->getQuery();
$queryList = explode("=", $query);
$params = [
'oauth_consumer_key' => $this->options->key,
'oauth_nonce' => $this->nonce(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => time(),
'oauth_token' => $token->accessToken,
'oauth_version' => '1.0',
'oauth_verifier' => $queryList[1],
];
$params['oauth_signature'] = $this->getSignature(
$request->getUri(),
$params,
$request->getMethod(),
$token->accessTokenSecret,
);
$header_auth = sprintf('OAuth %s', QueryUtil::build($params, null, ', ', '"'));
return $request->withHeader('Authorization', $header_auth);
} From $request param I can get the oauth_verifier, which is added to uri in sendAccessTokenRequest method. |
$verifier could be an optional param in getRequestAuthorization method to make the $params with oauth_verifier? |
Adding a non-interface parameter to this method is not advised as it is used in several places. This is a provider specific quirk that deviates from the RFC as the You can simplify fetching the parameter from the URI btw with the following: $queryList = QueryUtil::parse($request->getUri()->getQuery()); |
Wait, I need to correct myself: the php-oauth/src/Core/OAuth1Provider.php Lines 203 to 219 in 94aa904
|
In that getRequestAuthorization method from sendAccessTokenRequest method is where I'm needing the oauth_verifier to build the $params array. In fact, getRequestAuthorization method is only used in sendAccessTokenRequest method. |
That is the php-oauth/examples/example-oauth1.php Line 57 in 94aa904
|
I do that but I need the oauth_verifier in getRequestAuthorization method to build the $params aray such as: public function getRequestAuthorization(RequestInterface $request, AccessToken|null $token = null):RequestInterface{
$token ??= $this->storage->getAccessToken($this->name);
if($token->isExpired()){
throw new InvalidAccessTokenException;
}
$query = $request->getUri()->getQuery();
$queryList = explode("=", $query);
$params = [
'oauth_consumer_key' => $this->options->key,
'oauth_nonce' => $this->nonce(),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => time(),
'oauth_token' => $token->accessToken,
'oauth_version' => '1.0',
'oauth_verifier' => $queryList[1],
];
$params['oauth_signature'] = $this->getSignature(
$request->getUri(),
$params,
$request->getMethod(),
$token->accessTokenSecret,
);
$header_auth = sprintf('OAuth %s', QueryUtil::build($params, null, ', ', '"'));
return $request->withHeader('Authorization', $header_auth);
} To get the User Access Token for Garmin Connect Api the header "Authorization OAuth..." needs the oauth_verifier to work fine. |
Hmm, let me check what the other OAuth1 providers do with this parameter in the signature array, to see if this could be added in general (this might take me a moment). |
Sure. Thanks. |
Ok that was a larger rework - I've added a separate method for the request headers, as the Can you please check out from |
Hi. Sorry for letting you know so late. The update is working for me. Thank you so much and great job! |
That's great news! I'm going to tag it as version |
To get the User Access Token from Garmin Connect Api, I've used the public method getAccessToken in OAuth1Provider.php. In the public method getRequestAuthorization I've added oauth_verifier in the params:
Because without oauth_verifier I got an error in the response from Guzzle.
The text was updated successfully, but these errors were encountered: