Package com.google.refine.oauth

Examples of com.google.refine.oauth.Credentials


            throws ServletException, IOException {
       
        try {
            Provider provider = OAuthUtilities.getProvider(request);
           
            Credentials access_credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
           
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Type", "application/json");
           
            if (access_credentials != null) {
View Full Code Here


            Provider provider = OAuthUtilities.getProvider(request);
                       
            // this cookie should not be there, but this is good hygiene practice
            Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST);
           
            Credentials access_credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
           
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Type", "application/json");
           
            if (access_credentials != null) {
View Full Code Here

        String triples
    ) throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, JSONException, IOException {
               
        Provider provider = OAuthUtilities.getProvider(FREEBASE_HOST);
       
        Credentials credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
       
        JSONObject mdo_info = new JSONObject();
        mdo_info.put("name", source_name);
        if (source_id != null) {
            mdo_info.put("info_source",source_id);
View Full Code Here

        Provider provider = OAuthUtilities.getProvider(request);

        try {
           
            // see if the request comes with access credentials
            Credentials access_credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
                                   
            // prepare the continuation URL that the OAuth provider will redirect the user to
            // (we need to make sure this URL points back to this code or the dance will never complete)
            String callbackURL = getBaseURL(request,provider);
           
            if (access_credentials == null) {
                // access credentials are not available so we need to check
                // to see at what stage of the OAuth dance we are
               
                // get the request token credentials
                Credentials request_credentials = Credentials.getCredentials(request, provider, Credentials.Type.REQUEST);

                OAuthConsumer consumer = OAuthUtilities.getConsumer(request_credentials, provider);
                OAuthProvider pp = provider.getProvider();
               
                if (request_credentials == null) {
                    // no credentials were found, so let's start the dance

                    // get the request token

                    String url = pp.retrieveRequestToken(consumer, callbackURL);
                   
                    request_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider);

                    // and set them to that we can retrieve them later in the second part of the dance
                    Credentials.setCredentials(request, response, request_credentials, Credentials.Type.REQUEST, 3600);
                   
                    // now redirect the user to the Authorize URL where she can authenticate against the
                    // service provider and authorize us.
                    // The provider will bounce the user back here for us to continue the dance.
                   
                    response.sendRedirect(url);
                } else {
                    // we are at the second stage of the dance, so we need need to obtain the access credentials now
                   
                    // if we got here, it means that the user performed a valid authentication against the
                    // service provider and authorized us, so now we can request more permanent credentials
                    // to the service provider and save those as well for later use.

                    // this is set only for OAuth 1.0a 
                    String verificationCode = request.getParameter(OAUTH_VERIFIER_PARAM);
                   
                    pp.retrieveAccessToken(consumer, verificationCode);

                    access_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider);

                    // no matter the result, we need to remove the request token
                    Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST);
                   
                    Credentials.setCredentials(request, response, access_credentials, Credentials.Type.ACCESS, 30 * 24 * 3600);
 
View Full Code Here

TOP

Related Classes of com.google.refine.oauth.Credentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.