Workaround for Redirect_uri parameter error

Source: Internet
Author: User
Tags openid

I use Java code to get the user's OpenID, has been reported Redirect_uri. The link to my page code is:

https://open.weixin.qq.com/connect/oauth2/authorize?        appid=APPID&        redirect_uri=ENCODE(URL)&        response_type=code&        scope=snsapi_base&        state=state#wechat_redirect"

Where AppID is the project's Appid,encode (URL) for the URL that the link wants to jump to (URL requires urlencode), the URL of the ENCODE in Java code is implemented as follows:

        // url进行编码        "http://evan.tunnel.mobi/zzaClient/bindindex.html";        String url_encode = java.net.URLEncoder.encode"utf-8");        request.setAttribute("url_encode", url_encode);

When the current page construction is complete, clicking on the page link will jump to Bindindex.html's controller, where the controller's code is:

//need to be modified in the "Developer Center"---web account. Change to a domain name without HTTP. For example: Evan.tunnel  .mobi // Get OpenID String code = Request.getparameter  ()                 Jsonobject json = Weixinutils.getopenid  (Getopenid_url, app_id, Secret,        Code, )  String OpenID = Json.get  ( "OpenID" ) .getasstring  ()  Logger.info  (OpenID +  "------------------------- -----OpenID ")   

But oddly enough, all of the above parameters are not written correctly and the URL is encoded. However, the Redirect_uri parameter error is still reported. The solution is to change the "authorization callback page domain name" to the domain name of the server in the "Developer Center"-Web account-on the public platform.

In this way, OpenID is normally available. Some developers may have some questions, if every time I change to deploy to the formal environment for testing, which is a waste of time, in fact, we can map the local address to the external network through Ngrok, so that the development environment can map the address directly to the external network. See the blog for details:
http://blog.csdn.net/zl544434558/article/details/46593063

Finally, attach a picture of the error

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Workaround for Redirect_uri parameter error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.