Closed codemasternode closed 4 years ago
Hi @codemasternode. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
Hi @engcom-Oscar. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @codemasternode , thank you for your report. I couldn't reproduce this issue on the latest 2.4-develop branch. May you please provide additional details how you got such result?
Make sure you are making request without any proxy or domain setup in files like /etc/hosts. You have to make API call to strict Magento IP address.
@codemasternode Hi Marcin, I just encountered this issue. This looks like throttle is problematic part there:
public function createCustomerAccessToken($username, $password)
{
$this->validatorHelper->validate($username, $password);
$this->getRequestThrottler()->throttle($username, RequestThrottler::USER_TYPE_CUSTOMER);
try {
$customerDataObject = $this->accountManagement->authenticate($username, $password);
} catch (\Exception $e) {
$this->getRequestThrottler()->logAuthenticationFailure($username, RequestThrottler::USER_TYPE_CUSTOMER);
throw new AuthenticationException(
__(
'The account sign-in was incorrect or your account is disabled temporarily. '
. 'Please wait and try again later.'
)
);
}
getting same error. any updates?
same error here, any solution?
same here. first time ran dag: if the customer does not exist, it will create a customer, then generate token is failing. second time ran dag: this time any way customer exists(in the first dag ran customer created) but this time token successfully generating. https://github.com/sivajik34/magento-airflow/blob/main/src/example_dags/magento_customer_order_rest_demo.py
from airflow import DAG
from airflow.decorators import task
from datetime import datetime
from apache_airflow_provider_magento.operators.rest import MagentoRestOperator
default_args = {
'owner': 'airflow',
'retries': 0,
}
dag = DAG(
'magento_customer_order_rest_demo',
default_args=default_args,
description='Magento Customer Order Creation DAG',
schedule_interval=None,
start_date=datetime(2024, 8, 22),
catchup=False,
)
@task
def generate_customer_token(email: str, password: str, **kwargs) -> str:
op = MagentoRestOperator(
task_id='generate_customer_token_op',
endpoint='integration/customer/token',
method='POST',
data={'username': email, 'password': password}
)
response = op.execute(context=kwargs)
return response # Customer OAuth token
@task
def check_customer_exists(email: str, **kwargs) -> bool:
op = MagentoRestOperator(
task_id='check_customer_exists_op',
endpoint=f'customers/search?searchCriteria[filterGroups][0][filters][0][field]=email&searchCriteria[filterGroups][0][filters][0][value]={email}',
method='GET'
)
response = op.execute(context=kwargs)
return len(response.get('items', [])) > 0
@task
def create_customer(email: str, password: str, **kwargs) -> str:
op = MagentoRestOperator(
task_id='create_customer_op',
endpoint='customers',
method='POST',
data={
"customer": {"email": email, "firstname": "John", "lastname": "Doe", "website_id": 1, "store_id": 1, "group_id": 1},
"password": password
}
)
response = op.execute(context=kwargs)
return response.get('id')
@task.branch
def choose_path_for_customer(customer_exists: bool):
if customer_exists:
return 'generate_customer_token'
return ['create_customer','check_customer_exists','generate_customer_token']
@task.branch
def choose_path_for_product(product_exists: bool, sku: str):
if not product_exists:
return f'create_product_{sku}'
@task
def create_cart(customer_token: str, **kwargs) -> str:
op = MagentoRestOperator(
task_id='create_cart_op',
endpoint='carts/mine',
method='POST',
headers={'Authorization': f'Bearer {customer_token}'}
)
response = op.execute(context=kwargs)
return response # Returns quoteId
def generate_product_name(sku: str) -> str:
return f"Product Name - {sku}"
@task
def create_product(sku: str, price: float, **kwargs) -> str:
product_name = generate_product_name(sku)
product_data = {
"product": {
"sku": sku,
"name": product_name,
"price": price,
"status": 1,
"type_id": "simple",
"attribute_set_id": 4,
"weight": 1,
"extension_attributes": {
"stock_item": {"qty": 450, "is_in_stock": True}
}
}
}
op = MagentoRestOperator(
task_id=f'create_product_{sku}_op',
endpoint='products',
method='POST',
data=product_data,
)
response = op.execute(context=kwargs)
return response['sku']
@task
def check_product_exists(sku: str, **kwargs) -> bool:
op = MagentoRestOperator(
task_id=f'check_product_exists_{sku}_op',
endpoint=f'products/{sku}',
method='GET',
data={},
)
try:
response = op.execute(context=kwargs)
return True # Product exists
except Exception as e:
if '404' in str(e):
return False
else:
raise
@task
def add_product_to_cart(customer_token: str, quote_id: str, sku: str, qty: int, **kwargs):
op = MagentoRestOperator(
task_id=f'add_{sku}_to_cart_op',
endpoint=f'carts/mine/items',
method='POST',
headers={'Authorization': f'Bearer {customer_token}'},
data={"cartItem": {"quote_id": quote_id, "sku": sku, "qty": qty}}
)
response = op.execute(context=kwargs)
return response
@task
def set_billing_shipping_address(customer_token: str, quote_id: str, **kwargs):
op = MagentoRestOperator(
task_id='set_billing_shipping_address_op',
endpoint=f'carts/mine/shipping-information',
method='POST',
headers={'Authorization': f'Bearer {customer_token}'},
data={
"addressInformation": {
"shipping_address": {"region": "NY", "region_id": 43, "country_id": "US", "street": ["123 Main St"], "telephone": "1234567890", "postcode": "12345", "city": "New York", "firstname": "John", "lastname": "Doe", "email": customer_email},
"billing_address": {"region": "NY", "region_id": 43, "country_id": "US", "street": ["123 Main St"], "telephone": "1234567890", "postcode": "12345", "city": "New York", "firstname": "John", "lastname": "Doe", "email": customer_email},
"shippingMethodCode": "flatrate",
"shippingCarrierCode": "flatrate"
}
}
)
op.execute(context=kwargs)
@task
def set_payment_method(customer_token: str, quote_id: str, **kwargs):
op = MagentoRestOperator(
task_id='set_payment_method_op',
endpoint=f'carts/mine/payment-information',
method='POST',
headers={'Authorization': f'Bearer {customer_token}'},
data={"paymentMethod": {"method": "checkmo"}}
)
order_id = op.execute(context=kwargs)
return order_id
@task
def create_invoice(order_id: str, **kwargs):
op = MagentoRestOperator(
task_id='create_invoice_op',
endpoint=f'order/{order_id}/invoice',
method='POST',
data={
"capture": True,
"notify": True,
"appendComment": True,
"comment": {"comment": "Invoice created", "is_visible_on_front": 0}
}
)
op.execute(context=kwargs)
@task
def create_shipment(order_id: str, **kwargs):
op = MagentoRestOperator(
task_id='create_shipment_op',
endpoint=f'order/{order_id}/ship',
method='POST',
data={
"notify": True,
"appendComment": True,
"comment": {"comment": "Shipment created", "is_visible_on_front": 0},
"tracks": [{"track_number": "123456", "title": "Carrier", "carrier_code": "custom"}]
}
)
op.execute(context=kwargs)
with dag:
#make sure product exists in magento, as of now temp fix
sku_1 = 'product_sku_1'
sku_2 = 'product_sku_2'
price_1 = 100.00
price_2 = 150.00
qty=10
customer_email = 'customer485@example.com'
customer_password = 'Airflow@123'
customer_exists = check_customer_exists(customer_email)
next_task = choose_path_for_customer(customer_exists)
create_customer_task = create_customer(email=customer_email, password=customer_password)
customer_exists_task = check_customer_exists(customer_email)
generate_customer_token_task = generate_customer_token(email=customer_email, password=customer_password)
next_task >> [create_customer_task,customer_exists_task, generate_customer_token_task]
quote_id = create_cart(generate_customer_token_task)
generate_customer_token_task >> quote_id
#product_exists_1 = check_product_exists(sku_1)
#create_product_product_sku_1 = create_product(sku_1, price_1)
#next_task_product_1 = choose_path_for_product(product_exists_1, sku_1)
#next_task_product_1 >> create_product_product_sku_1
#product_exists_2 = check_product_exists(sku_2)
#create_product_product_sku_2 = create_product(sku_2, price_2)
#next_task_product_2 = choose_path_for_product(product_exists_2, sku_2)
#next_task_product_2 >> create_product_product_sku_2
add_product_1_to_cart = add_product_to_cart(generate_customer_token_task, quote_id, 'product_sku_1', qty)
add_product_2_to_cart = add_product_to_cart(generate_customer_token_task, quote_id, 'product_sku_2', qty)
#next_task_product_1 >> add_product_1_to_cart
#next_task_product_2 >> add_product_2_to_cart
# Task 6: Set billing and shipping address
set_billing_shipping_address_task = set_billing_shipping_address(customer_token=generate_customer_token_task, quote_id=quote_id)
# Task 7: Set payment method and place order
set_payment_method_task = set_payment_method(customer_token=generate_customer_token_task, quote_id=quote_id)
# Task 8: Create invoice
create_invoice_task = create_invoice(order_id=set_payment_method_task)
# Task 9: Create shipment
create_shipment_task = create_shipment(order_id=set_payment_method_task)
[add_product_1_to_cart, add_product_2_to_cart] >> set_billing_shipping_address_task >> set_payment_method_task
set_payment_method_task >> [create_invoice_task, create_shipment_task]
{magento.py:79} ERROR - Response body: {"message":"The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.","trace":"#0 [internal function]: Magento\Integration\Model\CustomerTokenService->createCustomerAccessToken('customer485@exa...', 'Airflow@123')\n#1 \/var\/www\/html\/vendor\/magento\/module-webapi\/Controller\/Rest\/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#2 \/var\/www\/html\/vendor\/magento\/module-webapi\/Controller\/Rest.php(201): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))\n#3 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#4 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->callParent('dispatch', Array)\n#5 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#6 \/var\/www\/html\/generated\/code\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->callPlugins('dispatch', Array, Array)\n#7 \/var\/www\/html\/vendor\/magento\/framework\/App\/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#8 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\Framework\App\Http->launch()\n#9 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->callParent('launch', Array)\n#10 \/var\/www\/html\/vendor\/magento\/module-application-performance-monitor\/Plugin\/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()\n#11 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch(Object(Magento\Framework\App\Http\Interceptor), Object(Closure))\n#12 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()\n#13 \/var\/www\/html\/generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->callPlugins('launch', Array, NULL)\n#14 \/var\/www\/html\/vendor\/magento\/framework\/App\/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()\n#15 \/var\/www\/html\/pub\/index.p
Preconditions (*)
Steps to reproduce (*)
{ "customer": { "id": 0, "group_id": 0, "email": "marcinwarzybok@outlook.com", "firstname": "Marcin", "lastname": "Warzybok" }, "password": "Abcdef123" }
Returns result:{ "id": 2, "group_id": 0, "created_at": "2020-09-08 11:58:13", "updated_at": "2020-09-08 11:58:13", "created_in": "Default Store View", "email": "marcinwarzybok@outlook.com", "firstname": "Marcin", "lastname": "Warzybok", "store_id": 1, "website_id": 1, "addresses": [], "disable_auto_group_change": 0, "extension_attributes": { "is_subscribed": false } }
Which means i have a new user registered.2.Execute API call on: "/rest/all/V1/integration/customer/token" with json body:
{ "username":"marcinwarzybok@outlook.com", "password":"Abcdef123" }
Returns error:{ "message": "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.", "trace": "#0 [internal function]: Magento\\Integration\\Model\\CustomerTokenService->createCustomerAccessToken('marcinwarzybok@...', 'Abcdef123')\n#1 /bitnami/magento/htdocs/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#2 /bitnami/magento/htdocs/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\\Webapi\\Controller\\Rest\\SynchronousRequestProcessor->process(Object(Magento\\Framework\\Webapi\\Rest\\Request\\Proxy))\n#3 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#4 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#5 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#6 /bitnami/magento/htdocs/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#7 /bitnami/magento/htdocs/vendor/magento/framework/App/Http.php(116): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#8 /bitnami/magento/htdocs/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\\Framework\\App\\Http->launch()\n#9 /bitnami/magento/htdocs/vendor/magento/framework/App/Bootstrap.php(263): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#10 /bitnami/magento/htdocs/index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#11 {main}" }
Expected result (*)
{ "username":"marcinwarzybok@outlook.com", "password":"Abcdef123" }
Should return token, according to this documentation: https://devdocs.magento.com/guides/v2.3/get-started/authentication/gs-authentication-token.html like this: "asdf3hjklp5iuytre"Actual result (*)
{ "username":"marcinwarzybok@outlook.com", "password":"Abcdef123" }
Returns error: ` { "message": "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.", "trace": "#0 [internal function]: Magento\Integration\Model\CustomerTokenService->createCustomerAccessToken('marcinwarzybok@...', 'Abcdef123')\n#1 /bitnami/magento/htdocs/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array)\n#2 /bitnami/magento/htdocs/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))\n#3 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#4 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->callParent('dispatch', Array)\n#5 /bitnami/magento/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#6 /bitnami/magento/htdocs/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->callPlugins('dispatch', Array, Array)\n#7 /bitnami/magento/htdocs/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#8 /bitnami/magento/htdocs/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()\n#9 /bitnami/magento/htdocs/vendor/magento/framework/App/Bootstrap.php(263): Magento\Framework\App\Http\Interceptor->launch()\n#10 /bitnami/magento/htdocs/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#11 {main}" }