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

h5上没法打开微信app授权界面 #447

Closed
xcaptain opened this issue Jul 3, 2016 · 6 comments
Closed

h5上没法打开微信app授权界面 #447

xcaptain opened this issue Jul 3, 2016 · 6 comments

Comments

@xcaptain
Copy link

xcaptain commented Jul 3, 2016

我用的环境

PHP 版本:php7
overtrue/wechat 版本:3.1.0

问题及现象

我在微信开放平台上创建了一个网页应用,应用审核通过,我自己的开发者认证也通过了,我目前实现了一个基本的PC站授权流程,scope设置为snsapi_login, PC浏览器访问/wechat/auth 跳转到二维码页面,然后用手机扫描二维码在手机上打开微信的授权页面,确认之后回调我自己的网站,创建用户,重定向页面都能成功。

现在的问题在于我用手机访问我网站的/wechat/auth地址的时候也会在手机浏览器上出现二维码页面,我想在手机访问的时候能直接跳转到微信授权页面,要改什么配置吗?求教。

@xcaptain
Copy link
Author

xcaptain commented Jul 3, 2016

可能是我的这个网站应用要绑定一个公众号才能使用scope=snsapi_userinfo吧,试试去。

@xcaptain
Copy link
Author

xcaptain commented Jul 3, 2016

问题解决了,看来如果是网站登录是用微信开发平台里面的配置,如果是h5、app的话就要用微信公众平台里面的配置。授权服务要做2个接口,一个PC网站授权,一个h5和app授权,回调接口是通用的。

剩下的疑问就是在微信开放平台里面的绑定公众号似乎没什么用,因为我是走了2个独立的接口来分别授权的。

@xcaptain xcaptain closed this as completed Jul 8, 2016
@lilywang711
Copy link

请问您最后是怎么做的 H5跳转到微信去授权呢?

@lilywang711
Copy link

@xcaptain

@xcaptain
Copy link
Author

xcaptain commented Jun 5, 2018

我的PC端扫码授权的代码是这样写的:

public function webauth(Application $wechat, Request $request)
{
    $response = $wechat->oauth->scopes(['snsapi_userinfo', 'snsapi_login'])
        ->redirect(Config('wechat.oauth.callback').'?referer='.$request->input('referer'));

    return $response;
}

微信内置浏览器跳转到授权页面的代码是:

public function auth(Application $wechat, Request $request)
{
    $response = $wechat->oauth->scopes(['snsapi_userinfo'])
        ->redirect(Config('wechat.oauth.callback').'?referer='.$request->input('referer'));

    return $response;
}

分不同的路由处理不同类型的授权方式

@lilywang711
Copy link

lilywang711 commented Jun 5, 2018

@xcaptain

微信内置浏览器跳转到授权页面的代码是...

那这个不是 从手机 非微信浏览器 跳转到微信浏览器登录授权的方式吗 (就像 手机打开www.qq.com 一样)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants