Skip to content
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

authkey is invalid error occurs when trying to resend otp #6

Closed
sahilsethchd opened this issue Mar 14, 2021 · 5 comments · Fixed by #7
Closed

authkey is invalid error occurs when trying to resend otp #6

sahilsethchd opened this issue Mar 14, 2021 · 5 comments · Fixed by #7
Assignees
Labels
bug Something isn't working released

Comments

@sahilsethchd
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
A clear test case to reproduce the bug

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here.

@sahilsethchd sahilsethchd added the bug Something isn't working label Mar 14, 2021
@sudkumar
Copy link
Contributor

Provide some context on the way you are resending the OTPs along with error responses.

@sudkumar sudkumar added Needs More Information and removed bug Something isn't working labels Mar 15, 2021
@sahilsethchd
Copy link
Author

Steps to recreate:

Create a new Laravel 8 project
Install msg91-laravel
Set the msg91 key with the appropriate values in config/services.php
In Api Controller, run Msg91::otp()->to(91xxxxxxxxxx)->send(); to receive the OTP. Then run Msg91::otp()->to(918888888888)->resend(); to resend.
The resendstatement throws the exception "Invalid authkey"

If you need additional information please let me know.

@sudkumar
Copy link
Contributor

Hey @sahilsethchd Just created a PR for this fix. The issue was related to request's content type headers.

Some apis requires form-data (resend and verify otps) while other requires json (send otp). Earlier resend OTP api was expecting json.

I have tested it on my end but you should test it as well and then I will merge.

Go to /vendor/craftsys/msg91-php/src/OTP/ResendRequest.php and set the content_type property as follows

class ResendRequest extends Request
{
    protected $url = URLs::OTP_RESEND_URL;
+
+   protected $content_type = \GuzzleHttp\RequestOptions::FORM_PARAMS;

If it fixed the problem, please update me here and I will push a new release.

@sudkumar sudkumar added bug Something isn't working and removed Needs More Information labels Mar 21, 2021
@sahilsethchd
Copy link
Author

Thanks for your reply. It resolved the issue.

Well, I checked the docs for MSG91 @ https://docs.msg91.com/p/tf9GTextN/e/7WESqQ4RLu/MSG91

It is clearly mentioned that they accept params in form-data (sendotp, resendotp and verifyotp) where as json required for sending Sms via flow.

@github-actions
Copy link

🎉 This issue has been resolved in version 0.15.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants