Java Code Examples for com.github.scribejava.core.oauth.OAuth10aService#getRequestToken()

The following examples show how to use com.github.scribejava.core.oauth.OAuth10aService#getRequestToken() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Oauth10aService.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
public String redirectUri(Provider provider) {
    OAuth10aService service = service(provider);
    try {
        OAuth1RequestToken requestToken = service.getRequestToken();
        sessionInfo.put(REQUEST_TOKEN_PREFIX + provider.name(), JSON.toJSON(requestToken));
        return service.getAuthorizationUrl(requestToken);
    } catch (InterruptedException | ExecutionException | IOException e) {
        throw new NotAuthorizedException("login failure", e);
    }
}
 
Example 2
Source File: MainActivity.java    From jam-collaboration-sample with Apache License 2.0 5 votes vote down vote up
public void beginOAuthLogin() {
    final OAuth10aService service = JamAuthConfig.instance().getOAuth10aService();

    AsyncTask network = new AsyncTask() {
        @Override
        protected Object doInBackground(Object[] params) {
            return service.getRequestToken();
        }

        @Override
        protected void onPostExecute(Object object) {
            super.onPostExecute(object);

            if (object != null) {
                final OAuth1RequestToken requestToken = (OAuth1RequestToken) object;
                String authUrl = service.getAuthorizationUrl(requestToken);

                JamOAuthDialog dialog = new JamOAuthDialog(MainActivity.this, authUrl);
                dialog.oauthListener = new JamOAuthDialog.ConfirmedOAuthAccessListener() {
                    @Override
                    public void onFinishOAuthAccess(String oauthToken, String oauthVerifier) {
                        processOAuthVerifier(requestToken, oauthVerifier);
                    }
                };
                dialog.show();
            }
        }
    };

    network.execute();
}
 
Example 3
Source File: TwitterController.java    From tutorials with MIT License 5 votes vote down vote up
@GetMapping(value = "/authorization")
public RedirectView authorization(HttpServletRequest servletReq) throws InterruptedException, ExecutionException, IOException {
    OAuth10aService twitterService = createService();

    OAuth1RequestToken requestToken = twitterService.getRequestToken();
    String authorizationUrl = twitterService.getAuthorizationUrl(requestToken);
    servletReq.getSession().setAttribute("requestToken", requestToken);

    RedirectView redirectView = new RedirectView();
    redirectView.setUrl(authorizationUrl);
    return redirectView;
}