// Path: postcard/src/main/java/org/scribe/oauth/OAuth20PostServiceImpl.java
// public class OAuth20PostServiceImpl extends OAuth20ServiceImpl{
// 
//     private static final String VERSION = "2.0";
//     private final DefaultApi20 api;
//     private final OAuthConfig config;
// 
//     public OAuth20PostServiceImpl(DefaultApi20 api, OAuthConfig config) {
//         super(api, config);
//         this.api = api;
//         this.config = config;
//     }
// 
//     @Override
//     public Token getAccessToken(Token requestToken, Verifier verifier)
//     {
//         OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
//         request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
//         request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
//         request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
//         request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
//         request.addBodyParameter("grant_type", "authorization_code");
//         if(config.hasScope()) request.addBodyParameter(OAuthConstants.SCOPE, config.getScope());
// 
//         Log.d("Oauth20PostImple", request.getBodyContents());
// 
//         Response response = request.send();
//         return api.getAccessTokenExtractor().extract(response.getBody());
//     }
// 
// }


import org.scribe.extractors.*;
import org.scribe.model.*;
import org.scribe.oauth.OAuth20PostServiceImpl;
import org.scribe.oauth.OAuthService;
import org.scribe.utils.*;
package org.scribe.builder.api;



/**
 *

 String redirectUri = "http://www.postcardsocial.net";
 String tokenUrl = "https://www.linkedin.com/uas/oauth2/";
 String tokenPath = "accessToken";
 String authorizationPath = "authorization";
 String authUrl =
 tokenUrl +
 authorizationPath +
 "?response_type=code&client_id=" +
 LINKEDIN_CLIENT_ID +
 "&scope=" +
 "r_fullprofile%20r_network%20rw_nus" +
 "&state=" +
 state +
 "&redirect_uri=" +
 redirectUri;

 try {
 JSONObject tokenPostData = new JSONObject();
 tokenPostData.put("client_id", LINKEDIN_CLIENT_ID);
 tokenPostData.put("client_secret", LINKEDIN_CLIENT_SECRET);
 tokenPostData.put("redirect_uri", redirectUri);
 tokenPostData.put("grant_type", "authorization_code");

 JSONObject params = new JSONObject();
 params.put("auth_url", authUrl);
 params.put("auth_type", "oauth2");
 params.put("code_title", "code");
 params.put("base_token_url", tokenUrl);
 params.put("token_path", tokenPath);
 params.put("token_method", "post");
 params.put("token_data", tokenPostData);
 params.put("token_title", "access_token");
 params.put("state", state);
 launchWebAuthActivity(params);
 } catch (JSONException ex) {
 ex.printStackTrace();
 }

 *
 */

public class LinkedIn20Api extends DefaultApi20
{
    private static final String AUTHORIZE_URL = "https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=%s&redirect_uri=%s&state=1234";
    private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=r_fullprofile%20r_network%20rw_nus"; //+ "&scope=%s";

    @Override
    public OAuthService createService(OAuthConfig config)
    {
// Path: postcard/src/main/java/org/scribe/oauth/OAuth20PostServiceImpl.java
// public class OAuth20PostServiceImpl extends OAuth20ServiceImpl{
// 
//     private static final String VERSION = "2.0";
//     private final DefaultApi20 api;
//     private final OAuthConfig config;
// 
//     public OAuth20PostServiceImpl(DefaultApi20 api, OAuthConfig config) {
//         super(api, config);
//         this.api = api;
//         this.config = config;
//     }
// 
//     @Override
//     public Token getAccessToken(Token requestToken, Verifier verifier)
//     {
//         OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
//         request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
//         request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
//         request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
//         request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
//         request.addBodyParameter("grant_type", "authorization_code");
//         if(config.hasScope()) request.addBodyParameter(OAuthConstants.SCOPE, config.getScope());
// 
//         Log.d("Oauth20PostImple", request.getBodyContents());
// 
//         Response response = request.send();
//         return api.getAccessTokenExtractor().extract(response.getBody());
//     }
// 
// }


// Path: postcard/src/main/java/org/scribe/builder/api/LinkedIn20Api.java
import org.scribe.extractors.*;
import org.scribe.model.*;
import org.scribe.oauth.OAuth20PostServiceImpl;
import org.scribe.oauth.OAuthService;
import org.scribe.utils.*;

package org.scribe.builder.api;



/**
 *

 String redirectUri = "http://www.postcardsocial.net";
 String tokenUrl = "https://www.linkedin.com/uas/oauth2/";
 String tokenPath = "accessToken";
 String authorizationPath = "authorization";
 String authUrl =
 tokenUrl +
 authorizationPath +
 "?response_type=code&client_id=" +
 LINKEDIN_CLIENT_ID +
 "&scope=" +
 "r_fullprofile%20r_network%20rw_nus" +
 "&state=" +
 state +
 "&redirect_uri=" +
 redirectUri;

 try {
 JSONObject tokenPostData = new JSONObject();
 tokenPostData.put("client_id", LINKEDIN_CLIENT_ID);
 tokenPostData.put("client_secret", LINKEDIN_CLIENT_SECRET);
 tokenPostData.put("redirect_uri", redirectUri);
 tokenPostData.put("grant_type", "authorization_code");

 JSONObject params = new JSONObject();
 params.put("auth_url", authUrl);
 params.put("auth_type", "oauth2");
 params.put("code_title", "code");
 params.put("base_token_url", tokenUrl);
 params.put("token_path", tokenPath);
 params.put("token_method", "post");
 params.put("token_data", tokenPostData);
 params.put("token_title", "access_token");
 params.put("state", state);
 launchWebAuthActivity(params);
 } catch (JSONException ex) {
 ex.printStackTrace();
 }

 *
 */

public class LinkedIn20Api extends DefaultApi20
{
    private static final String AUTHORIZE_URL = "https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=%s&redirect_uri=%s&state=1234";
    private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=r_fullprofile%20r_network%20rw_nus"; //+ "&scope=%s";

    @Override
    public OAuthService createService(OAuthConfig config)
    {
        return new OAuth20PostServiceImpl(this, config);