Search in sources :

Example 66 with OAuth20Service

use of com.github.scribejava.core.oauth.OAuth20Service in project legendarybot by greatman.

the class LinkWoWCharsCommand method execute.

@Override
public void execute(MessageReceivedEvent event, String[] args) {
    String region = plugin.getBot().getGuildSettings(event.getGuild()).getRegionName();
    if (region == null) {
        event.getChannel().sendMessage("The Region is not configured. Please ask a server admin to configure it with the setup command").queue();
        return;
    }
    OAuth20Service service = new ServiceBuilder(plugin.getProps().getProperty("battlenetoauth.key")).scope("wow.profile").callback("https://legendarybot.greatmancode.com/auth/battlenetcallback").state(region + ":" + event.getAuthor().getId()).build(new OAuthBattleNetApi(region));
    event.getAuthor().openPrivateChannel().queue((privateChannel -> privateChannel.sendMessage("Please follow this link to connect your WoW account to this bot: " + service.getAuthorizationUrl()).queue()));
    log.info("User " + event.getAuthor().getName() + ":" + event.getAuthor().getId() + " requested to link his characters. Link generated: " + service.getAuthorizationUrl());
}
Also used : OAuthBattleNetApi(com.greatmancode.legendarybot.plugins.wowlink.utils.OAuthBattleNetApi) ZeroArgsCommand(com.greatmancode.legendarybot.api.commands.ZeroArgsCommand) ServiceBuilder(com.github.scribejava.core.builder.ServiceBuilder) Logger(org.slf4j.Logger) MessageReceivedEvent(net.dv8tion.jda.core.events.message.MessageReceivedEvent) LoggerFactory(org.slf4j.LoggerFactory) OAuth20Service(com.github.scribejava.core.oauth.OAuth20Service) PublicCommand(com.greatmancode.legendarybot.api.commands.PublicCommand) WoWLinkPlugin(com.greatmancode.legendarybot.plugins.wowlink.WoWLinkPlugin) OAuthBattleNetApi(com.greatmancode.legendarybot.plugins.wowlink.utils.OAuthBattleNetApi) OAuth20Service(com.github.scribejava.core.oauth.OAuth20Service) ServiceBuilder(com.github.scribejava.core.builder.ServiceBuilder)

Aggregations

OAuth20Service (com.github.scribejava.core.oauth.OAuth20Service)66 OAuth2AccessToken (com.github.scribejava.core.model.OAuth2AccessToken)51 ServiceBuilder (com.github.scribejava.core.builder.ServiceBuilder)50 OAuthRequest (com.github.scribejava.core.model.OAuthRequest)45 Response (com.github.scribejava.core.model.Response)45 Scanner (java.util.Scanner)40 Random (java.util.Random)17 HashMap (java.util.HashMap)6 OAuthException (com.github.scribejava.core.exceptions.OAuthException)4 AccessTokenResponseDetails (alfio.util.oauth2.AccessTokenResponseDetails)3 NingHttpClientConfig (com.github.scribejava.httpclient.ning.NingHttpClientConfig)3 AsyncHttpClientConfig (com.ning.http.client.AsyncHttpClientConfig)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 AsyncSimpleTask (com.codepath.utils.AsyncSimpleTask)2 SalesforceToken (com.github.scribejava.apis.salesforce.SalesforceToken)2 OAuth1RequestToken (com.github.scribejava.core.model.OAuth1RequestToken)2 OAuth10aService (com.github.scribejava.core.oauth.OAuth10aService)2 OAuthBattleNetApi (com.greatmancode.legendarybot.plugins.wowlink.utils.OAuthBattleNetApi)2 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2