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

com.hn.im.easemob.api.impl.EasemobAuthToken Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.hn.im.easemob.api.impl;

import com.hn.im.easemob.api.AuthTokenAPI;
import com.hn.im.easemob.api.EasemobRestAPI;
import com.hn.im.easemob.comm.body.AuthTokenBody;
import com.hn.im.easemob.comm.constant.HTTPMethod;
import com.hn.im.easemob.comm.helper.HeaderHelper;
import com.hn.im.easemob.comm.wrapper.BodyWrapper;
import com.hn.im.easemob.comm.wrapper.HeaderWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class EasemobAuthToken extends EasemobRestAPI implements AuthTokenAPI {
	
	public static final String ROOT_URI = "/token";
	
	private static final Logger log = LoggerFactory.getLogger(EasemobAuthToken.class);
	
	@Override
	public String getResourceRootURI() {
		return ROOT_URI;
	}

	public Object getAuthToken(String clientId, String clientSecret) {
		String url = getContext().getSeriveURL() + getResourceRootURI();
		BodyWrapper body = new AuthTokenBody(clientId, clientSecret);
		HeaderWrapper header = HeaderHelper.getDefaultHeader();
		
		return getInvoker().sendRequest(HTTPMethod.METHOD_POST, url, header, body, null);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy