Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the combination of laravel passport and SMS login?

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the combination of laravel passport and SMS login". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the combination of laravel passport and SMS login?"

Preparation steps

Laravel passport environment

How to install and how to use it, just read the documentation. Here, record the hole with SMS and how to combine with passport.

Kengichi

Easy-sms package interfacing with Tencent Cloud, please use version 1.3 and version 2.0 will consistently report that the error cannot be sent. I have repeatedly tested it several times, which is simply killing me, and if code contains letters, he will prompt me that there is something wrong with my signature. The interface of Tencent Cloud under the real name diss is speechless.

Pit two

Judge CAPTCHA match, create a user, then how to give him token, Baidu has a bunch of methods, everything is miscellaneous, everything has been tried, not only support laravel5 or version, otherwise what kind of simply

If ($innerVerificationCode==$verificationCode) {/ / CAPTCHA is successful, which is judged by the fact that the user of this mobile phone is in the database. If the token is not created immediately, give him token $user=User::query ()-> where ('phone_number', $phoneNumber)-> first (); if (! $user) {$user= new User (); $user- > name = $phoneNumber; $user- > phone_number= $phoneNumber; $user- > login_type=User::USER_LOGIN_TYPE_PHONE; $user- > password = bcrypt (' 12345678') $user- > save ();} return $this- > getToken ($user, 'id');} / / has been struggling with how to give him access_token directly without an account password, but has not failed for various reasons? then the api request public function getToken ($user, $type) {$http = new\ GuzzleHttp\ Client () $response = $http- > post (config ('app.url').' / api/fund/oauth/token', ['form_params' = > [' grant_type' = > 'password',' username' = > $user- > $type,// user name that can be directly logged in to the user, after configuration, can also be a mailbox, version 5.8 This defaults to the registered mailbox 'password' = >' 12345678 password corresponding to 'scope' = >' *',],]) Return json_decode ($response- > getBody (), false);}

The code of the access_token API is as follows:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report