-
Notifications
You must be signed in to change notification settings - Fork 8
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
The scope
argument for the ClientCredentials leads to a 400 Bad Request
response
#177
Comments
Hi. Either omit the scope or use the scope including the project key ('manage_project:your-project-key') |
But for what purposes the function ClientCredentials::__construct(
string $clientId,
string $clientSecret,
string $scope = null
) Omitting the scope works well, but including it into the the project key - doesn't work: const PROJECT_KEY = 'manage_project:drupal-connector';
$builder = new ApiRequestBuilder($client);
$request = $builder->withProjectKey(PROJECT_KEY)->get(); Produces a 404 error:
|
The scope is needed when you have a client with multiple permissions but you want only a token for a specific scope, e.g.: Client scope: And i didn't meant to use the scope in the project key, but to suffix the scope with it. The way it's presented in the MC. In the V1 SDK there was log to combine the scope and project key.
But as the oauth server will default a token request to the client permissions if the scope is being omitted. The best practice is to create a client in the Merchant Center with the needed permissions and omit the scope when requesting the token. |
Thank you for the information! Will be good to document this too! ;) /**
* The constructor of the ClientCredentials class.
*
* @param string $clientId
* The client id.
* @param string $clientSecret
* The client secret.
* @param string $scope
* The scope is needed when you have a client with multiple permissions
* but you want only a token for a specific scope.
* Format: `<the scope name>:<the project key>`.
* Example: `manage_products:project1`.
*/
public function __construct(string $clientId, string $clientSecret, string $scope = NULL) {
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
$this->scope = $scope;
$this->cacheKey = sha1($clientId . (string) $scope);
} but saw that it is auto-generated, so just extended the readme and created a PR #178 - please review. And maybe we still can add PHPDocs to the autogenerated files somehow? |
Thanks for your contribution @MurzNN 💯 I would close this issue, but please feel free to open another one if you have any problems |
Describe the bug
I'm migrating from the v1 to the v2 version of the library. In the v1 the
scope
argument worked well, but with v2 I'm receiving a400 Bad Request
response.To Reproduce
scope
argument to theClientCredentials
constructor, like this:400 Bad Request
response error:scope
argument from the constructor, like this:and see that the error disappears.
Expected behavior
The
scope
argument should not produce the error.So, maybe in the v2 of the API, the scope should be passed via a different way?
Screenshots/Code snippet
Here is a code to reproduce the problem:
Stack information (please complete the following information):
The text was updated successfully, but these errors were encountered: