All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.healthy.common.security.social.weixin.connet.WeixinOAuth2ServiceProvider Maven / Gradle / Ivy

There is a newer version: 1.2.1.RELEASE
Show newest version
package com.healthy.common.security.social.weixin.connet;

import com.healthy.common.security.social.weixin.api.Weixin;
import com.healthy.common.security.social.weixin.api.impl.WeixinImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

/**
 * 微信的OAuth2流程处理器的提供器,供spring social的connect体系调用
 */
public class WeixinOAuth2ServiceProvider extends AbstractOAuth2ServiceProvider {

    /**
     * 微信获取授权码的url
     */
    private static final String URL_AUTHORIZE = "https://open.weixin.qq.com/connect/qrconnect";
    /**
     * 微信获取accessToken的url
     */
    private static final String URL_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token";

    /**
     * @param appId
     * @param appSecret
     */
    public WeixinOAuth2ServiceProvider(String appId, String appSecret) {
        super(new WeixinOAuth2Template(appId, appSecret, URL_AUTHORIZE, URL_ACCESS_TOKEN));
    }

    /**
     * @param accessToken
     * @return
     * @see AbstractOAuth2ServiceProvider#getApi(String)
     */
    @Override
    public Weixin getApi(String accessToken) {
        return new WeixinImpl(accessToken);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy