Commit 958d8db3c4276b65c05d8f1fbcc6791a9b3de102

Authored by Paulo Graça
1 parent 4c94a28895

Initial documentation version

Showing 1 changed file with 87 additions and 0 deletions   Show diff stats
@@ -0,0 +1,87 @@ @@ -0,0 +1,87 @@
  1 +# JAVA-ORCID-CLIENT
  2 +
  3 +# Usage Examples
  4 +
  5 +## Requirements
  6 +
  7 +You should import:
  8 +
  9 + // Import the client
  10 + import org.um.dsi.gavea.orcid.client.OrcidOAuthClient;
  11 + import org.um.dsi.gavea.orcid.client.OrcidAccessToken;
  12 + import org.um.dsi.gavea.orcid.client.exception.OrcidClientException;
  13 +
  14 + // Import activities
  15 + import org.um.dsi.gavea.orcid.model.activities.ActivitiesSummary;
  16 + import org.um.dsi.gavea.orcid.model.activities.Identifier;
  17 + import org.um.dsi.gavea.orcid.model.activities.WorkGroup;
  18 +
  19 + // Import Works
  20 + import org.um.dsi.gavea.orcid.model.work.ExternalIdentifier;
  21 + import org.um.dsi.gavea.orcid.model.work.ExternalIdentifierType;
  22 + import org.um.dsi.gavea.orcid.model.work.Work;
  23 + import org.um.dsi.gavea.orcid.model.work.WorkExternalIdentifiers;
  24 + import org.um.dsi.gavea.orcid.model.work.WorkTitle;
  25 + import org.um.dsi.gavea.orcid.model.work.WorkType;
  26 +
  27 + // Import Enum types
  28 + import org.um.dsi.gavea.orcid.model.common.RelationshipType;
  29 + import org.um.dsi.gavea.orcid.model.common.ScopePathType;
  30 +
  31 +
  32 +
  33 +## Generate an Access Token, using the sandbox
  34 + String loginUri = "https://sandbox.orcid.org";
  35 + String clientSecret = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
  36 + String clientId = "XXXX-XXXX-XXXX-XXXX";
  37 + String apiUri = "https://api.sandbox.orcid.org";
  38 + //Use google OAUTH playground, this should be the landing page used to receive the Authorization Code
  39 + String redirectUri = "https://developers.google.com/oauthplayground";
  40 +
  41 + // This scopes will allow you to do almost anything to the user profile
  42 + // You should limit the scopes you want to use
  43 + List<ScopePathType> scopes = new ArrayList<ScopePathType>();
  44 + scopes.add(ScopePathType.AUTHENTICATE);
  45 + scopes.add(ScopePathType.ORCID_PROFILE_READ_LIMITED);
  46 + scopes.add(ScopePathType.ACTIVITIES_UPDATE);
  47 + scopes.add(ScopePathType.ORCID_BIO_UPDATE);
  48 +
  49 + // Instantiate the Orcid Client
  50 + OrcidOAuthClient orcidClient = new OrcidOAuthClient(loginUri, apiUri, clientId, clientSecret, redirectUri);
  51 +
  52 + try {
  53 + String authorizationURI = orcidClient.getAuthorizeUriLogin(scopes,state,orcid);
  54 + System.out.println(authorizationURI);
  55 + } catch (Exception e) {
  56 + // TODO Auto-generated catch block
  57 + e.printStackTrace();
  58 + }
  59 +
  60 +Then you should have a landing page in your project, configured in redirectUri to get the Authentication Code
  61 +This method will
  62 +
  63 + OrcidAccessToken orcidToken;
  64 +
  65 + try {
  66 + orcidToken = orcidClient.getAccessTokens(authorizationCode);
  67 + accessToken = orcidToken.getAccess_token();
  68 + System.out.println(accessToken);
  69 +
  70 + } catch (OrcidClientException e) {
  71 + // TODO Auto-generated catch block
  72 + e.printStackTrace();
  73 + }
  74 +
  75 +## Get activities
  76 +
  77 +## Get a Work
  78 +
  79 +## Update a Work
  80 +
  81 +## Create a new Work
  82 +
  83 +
  84 +
  85 +
  86 +#License
  87 +See [LICENSE.md](https://github.com/ORCID/ORCID-Work-in-Progress/blob/master/LICENSE.md)