Connect to the OVH API using a consumerKey

@param consumerKey
the consumerKey
@return an ApiOvhCore authenticate by consumerKey
762533
public static ApiOvhCore getInstance(String consumerKey) {
		ApiOvhCore core = new ApiOvhCore();
		core._consumerKey = consumerKey;
		return core;
	}
738448
protected OAuthProviderToken createOAuthToken(ConsumerAuthentication authentication) {
    return getTokenServices().createUnauthorizedRequestToken(authentication.getConsumerDetails().getConsumerKey(),
                                                             authentication.getOAuthParameters().get(OAuthConsumerParameter.oauth_callback.toString()));
  }
938241
public static Key<?> getProvidedKey(Key<?> key) {
    Type providerType = key.getTypeLiteral().getType();

    // If the Provider has no type parameter (raw Provider)...
    Preconditions.checkArgument(providerType instanceof ParameterizedType,
        "Expected all providers to be parameterized, but %s wasn't", key);

    Type entryType = ((ParameterizedType) providerType).getActualTypeArguments()[0];

    return key.ofType(entryType);
  }
874844
public static sslcertkey_binding get(nitro_service service, String certkey) throws Exception{
		sslcertkey_binding obj = new sslcertkey_binding();
		obj.set_certkey(certkey);
		sslcertkey_binding response = (sslcertkey_binding) obj.get_resource(service);
		return response;
	}
296325
protected Client getClient(String apiKey) throws SQLException {
        Client client;
        synchronized (mutex) {
            client = clientCache.get(apiKey);
        }

        if (client == null) {
            client = super.getClientInternal(apiKey);
            synchronized (mutex) {
                if (client != null) {
                    clientCache.put(apiKey, client);
                }
            }
        }

        return client;
    }
424046
private ItemDataProvider connect(boolean sync, InputReader in) {
		//read app's consumer key and secret
		String[] consumer;
		try {
			consumer = readConsumer();
		} catch (Exception e) {
			//should never happen
			throw new RuntimeException("Could not read OAuth consumer key and secret");
		}
		
		//use previously stored authentication
		File authStoreFile = new File(CSLToolContext.current().getConfigDir(),
				getAuthStoreFileName());
		AuthenticationStore authStore;
		try {
			authStore = new FileAuthenticationStore(authStoreFile);
		} catch (IOException e) {
			error("could not read user's authentication store: " + authStoreFile.getPath());
			return null;
		}
		
		//connect to remote server
		RemoteConnector dmc = createRemoteConnector(consumer[0], consumer[1]);
		dmc = new AuthenticatedRemoteConnector(dmc, authStore);
		
		//enable cache
		File cacheFile = new File(CSLToolContext.current().getConfigDir(),
				getCacheFileName());
		CachingRemoteConnector mc = new CachingRemoteConnector(dmc, cacheFile);
		
		//clear cache if necessary
		if (sync) {
			mc.clear();
		}

		List<CSLItemData> itemDataList;
		int retries = 1;
		while (true) {
			try {
				//download list of item IDs
				boolean cacheempty = false;
				if (!mc.hasItemList()) {
					System.out.print("Retrieving items ...");
					cacheempty = true;
				}
				List<String> items = mc.getItemIDs();
				if (cacheempty) {
					System.out.println();
				}
				
				//download all items
				itemDataList = new ArrayList<>(items.size());
				int s = 0;
				int printed = 0;
				int bulk = mc.getMaxBulkItems();
				if (bulk == 1) {
					mc.beginTransaction();
				}
				
				while (s < items.size()) {
					int n = 0;
					List<String> itemsToRetrieve = new ArrayList<>(bulk);
					while (s < items.size() && n < bulk) {
						String did = items.get(s);
						if (!mc.containsItemId(did)) {
							String msg = String.format("\rSynchronizing (%d/%d) ...",
									s + 1, items.size());
							System.out.print(msg);
							++printed;
							++n;
						}
						itemsToRetrieve.add(did);
						++s;
					}
					Map<String, CSLItemData> itemData = mc.getItems(itemsToRetrieve);
					itemDataList.addAll(itemData.values());
					
					if (bulk == 1 && s % 10 == 0) {
						mc.commitTransaction();
					}
				}
				
				if (bulk == 1) {
					mc.commitTransaction();
					mc.endTransaction();
				}
				
				if (printed > 0) {
					System.out.println();
				}
			} catch (UnauthorizedException e) {
				if (retries == 0) {
					error("failed to authorize.");
					return null;
				}
				--retries;
				
				//app is not authenticated yet
				System.out.print("\r"); //overwrite 'Retrieving items' message
				if (!authorize(mc, in)) {
					return null;
				}
				
				continue;
			} catch (RequestException e) {
				error(e.getMessage());
				return null;
			} catch (IOException e) {
				error("could not get list of items from remote server.");
				return null;
			}
			
			break;
		}
		
		//return provider that contains all items from the server
		CSLItemData[] itemDataArr = itemDataList.toArray(new CSLItemData[itemDataList.size()]);
		return createItemDataProvider(itemDataArr);
	}
828008
public static FaceAPI authenticate(String baseUrl, final String subscriptionKey) {
        ServiceClientCredentials serviceClientCredentials = new ServiceClientCredentials() {
            @Override
            public void applyCredentialsFilter(OkHttpClient.Builder builder) {
                builder.addNetworkInterceptor(
                        new Interceptor() {
                            @Override
                            public Response intercept(Chain chain) throws IOException {
                                Request request = null;
                                Request original = chain.request();
                                // Request customization: add request headers
                                Request.Builder requestBuilder = original.newBuilder()
                                        .addHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
                                request = requestBuilder.build();
                                return chain.proceed(request);
                            }
                        });
            }
        };
        return authenticate(baseUrl, serviceClientCredentials);
    }
1203033
def auth(
        cls, consumer_key, redirect_uri='http://example.com/', state=None,
    ):
        '''
        

        '''
        code = cls.get_request_token(consumer_key, redirect_uri, state)

        auth_url = 'https://getpocket.com/auth/authorize?request_token='\
            '%s&redirect_uri=%s' % (code, redirect_uri)
        raw_input(
            'Please open %s in your browser to authorize the app and '
            'press enter:' % auth_url
        )

        return cls.get_access_token(consumer_key, code)
101383
public static JSONObject oauth(String apiKey, String secretKey, AipClientConfiguration config) {
        try {
            AipRequest request = new AipRequest();
            request.setUri(new URI(AipClientConst.OAUTH_URL));
            request.addBody("grant_type", "client_credentials");
            request.addBody("client_id", apiKey);
            request.addBody("client_secret", secretKey);
            request.setConfig(config);
            int statusCode = 500;
            AipResponse response = null;
            // add retry
            int cnt = 0;
            while (statusCode == 500 && cnt < 3) {
                response = AipHttpClient.post(request);
                statusCode = response.getStatus();
                cnt++;
            }
            String res = response.getBodyStr();
            if (res != null && !res.equals("")) {
                return new JSONObject(res);
            } else {
                return Util.getGeneralError(statusCode, "Server response code: " + statusCode);
            }
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return Util.getGeneralError(-1, "unknown error");
    }
841520
public ReplicationClientFactory usingApiKey(String apiKey) {
        if (Objects.equal(_apiKey, apiKey)) {
            return this;
        }
        return new ReplicationClientFactory(_jerseyClient, apiKey);
    }
388379
@Override
    public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response)
            throws IllegalStateException {
        if (this.wrappedComponent != null) {
            return this.wrappedComponent.getCacheKey(request, response);
        } else {
            logger.debug("PipelineComponentWrapper.wrapperComponent is null");
            throw new IllegalStateException("PipelineComponentWrapper.wrapperComponent is null");
        }
    }
449973
public function lookup_consumer($consumer_key)
	{
		$returnValue = null;

		$consumer = $this->findOauthConsumerResource($consumer_key);
		$secret			= (string)$consumer->getUniquePropertyValue($this->getProperty(self::PROPERTY_OAUTH_SECRET));
		$callbackUrl	= null;
		
		$returnValue = new OAuthConsumer($consumer_key, $secret, $callbackUrl);

		return $returnValue;
	}
437826
public ConsumerKeyGroup joinKeyGroup(ConsumerKey consumerKey, OrderingContextImpl orderingGroup) 
  throws SIResourceException, SISessionDroppedException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "joinKeyGroup", new Object[] {consumerKey, orderingGroup});

    JSKeyGroup keyGroup = null;

    // We need to hold the keyGroup lock while we add a member (to prevent the
    // member count (and therefore the ready state) changing under an existing
    // member's feet). We also need the readyConsumerPointLock while we're adding
    // a new keyGroup to the hashmap (as users of different groups may attempt to
    // join at the same time). But we cannot hold the readyConsumerPointLock while we
    // do this as it is below the keyGroup lock in the hierarchy. Instead we lock
    // the orderingGroup as a whole, this prevents anyone else trying to come along
    // and join a new keyGroup (and possibly leave it - causing it to be removed)
    // before we manage to add ourselves to it.
    synchronized(orderingGroup)
    {
      synchronized(_baseDestHandler.getReadyConsumerPointLock())
      {
        // See if a keyGroup (specific to a CD) for the supplied orderingGroup is
        // currently attached to this CD
        if((keyGroup = keyGroups.get(orderingGroup)) == null)
        {
          // If not, create one
          // We pass the consumerSet as parameter. This will only be non-null
          // where XD has registered for message classification
          JSConsumerSet consumerSet = null;
          if(consumerKey instanceof ConsumableKey)
          {
            consumerSet = ((ConsumableKey)consumerKey).getConsumerSet();
            keyGroup = createConsumerKeyGroup(consumerSet);
            if (keyGroup!=null)
              keyGroups.put(orderingGroup, keyGroup);
          }
        }
      }

      //Add this key to the keyGroup
      if (keyGroup!=null)
        ((ConsumableKey) consumerKey).joinKeyGroup(keyGroup);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "joinKeyGroup", keyGroup);

    return keyGroup;
  }
1180676
public static ApiOvhCore getInstance() {
		ApiOvhCore core = new ApiOvhCore();
		// core._consumerKey = core.config.getConsumerKey();
		core._consumerKey = core.getConsumerKeyOrNull();// config.getConsumerKey();
		if (core._consumerKey == null) {
			File file = ApiOvhConfigBasic.getOvhConfig();
			String location = ApiOvhConfigBasic.configFiles;
			if (file != null)
				location = file.getAbsolutePath();
			String url = "";
			String CK = "";
			try {
				OvhCredential credential = core.requestToken(null);
				url = credential.validationUrl;
				CK = credential.consumerKey;
			} catch (Exception e) {
				log.error("Fail to request a new Credential", e);
			}
			log.error("activate the CK {} here: {}", CK, url);
			throw new NullPointerException("no 'consumer_key' present in " + location
					+ " or environement 'OVH_CONSUMER_KEY', activate the CK '" + CK + "' here: " + url);
		}
		return core;
	}
385713
def lookup_cert(self, key):
        
        if not self.consumers:
            log.critical(("No consumers defined in settings."
                          "Have you created a configuration file?"))
            return None

        consumer = self.consumers.get(key)
        if not consumer:
            log.info("Did not find consumer, using key: %s ", key)
            return None
        cert = consumer.get('cert', None)
        return cert
1118105
public function lookup_consumer($consumerkey) {
        if (strpos($consumerkey, "http://" ) === 0) {
            $consumer = new OAuthConsumer($consumerkey, "secret", null);
            return $consumer;
        }
        if ( $this->consumers[$consumerkey] ) {
            $consumer = new OAuthConsumer($consumerkey, $this->consumers[$consumerkey], null);
            return $consumer;
        }
        return null;
    }
1292390
public ConsumableKey attachToLocalDurableSubscription(
                                                          LocalConsumerPoint consumerPoint,
                                                          ConsumerDispatcherState subState)
                    throws
                    SIDurableSubscriptionMismatchException,
                    SIDurableSubscriptionNotFoundException,
                    SIDestinationLockedException,
                    SISelectorSyntaxException,
                    SIDiscriminatorSyntaxException,
                    SINotPossibleInCurrentConfigurationException,
                    SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "attachToLocalDurableSubscription",
                        new Object[] { consumerPoint, subState });

        ConsumerDispatcher consumerDispatcher = null;
        ConsumableKey data = null;
        /*
         * Lock the list of durable subscriptions to prevent others creating/using an
         * identical subscription
         */
        synchronized (_consumerDispatchersDurable)
        {
            /*
             * Get the consumerDispatcher. If it does not exist then we create it. If it exists
             * already and is EXACTLY the same, then we connect to it. If it exists but only
             * the same in ID then throw exception.
             */
            consumerDispatcher = getDurableSubscriptionConsumerDispatcher(subState);

            if (consumerDispatcher != null)
            {
                // If subscription already has consumers attached then reject the create
                // unless we are setting up a cloned subscriber.
                if (consumerDispatcher.hasConsumersAttached() && !subState.isCloned())
                {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.exit(
                                   tc,
                                   "attachToLocalDurableSubscription",
                                   "Consumers already attached");

                    throw new SIDestinationLockedException(
                                    nls.getFormattedMessage(
                                                            "SUBSCRIPTION_IN_USE_ERROR_CWSIP0152",
                                                            new Object[] {
                                                                          subState.getSubscriberID(),
                                                                          _messageProcessor.getMessagingEngineName() },
                                                            null));
                }

                // Attach to the consumerDispatcher if it is EXACTLY the same
                if (!consumerDispatcher.getConsumerDispatcherState().isReady()
                    || !consumerDispatcher.getConsumerDispatcherState().equals(subState))
                {
                    // Found consumer dispatcher but only the IDs match, therefore cannot connect
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.exit(tc, "attachToLocalDurableSubscription", subState);

                    throw new SIDurableSubscriptionMismatchException(
                                    nls.getFormattedMessage(
                                                            "SUBSCRIPTION_ALREADY_EXISTS_ERROR_CWSIP0143",
                                                            new Object[] {
                                                                          subState.getSubscriberID(),
                                                                          _messageProcessor.getMessagingEngineName() },
                                                            null));
                }

                // If security is enabled, then check the user who is attempting
                // to attach matches the user who created the durable sub.
                if (_messageProcessor.isBusSecure())
                {
                    if (!consumerDispatcher
                                    .getConsumerDispatcherState()
                                    .equalUser(subState))
                    {
                        // Users don't match
                        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                            SibTr.exit(tc, "attachToLocalDurableSubscription", subState);

                        throw new SIDurableSubscriptionMismatchException(
                                        nls.getFormattedMessage(
                                                                "USER_NOT_AUTH_ACTIVATE_ERROR_CWSIP0312",
                                                                new Object[] {
                                                                              subState.getUser(),
                                                                              subState.getSubscriberID(),
                                                                              _baseDestinationHandler.getName() },
                                                                null));
                    }
                }

                // Attach the consumerpoint to the subscription.
                data =
                                (ConsumableKey) consumerDispatcher.attachConsumerPoint(
                                                                                       consumerPoint,
                                                                                       null,
                                                                                       consumerPoint.getConsumerSession().getConnectionUuid(),
                                                                                       consumerPoint.getConsumerSession().getReadAhead(),
                                                                                       consumerPoint.getConsumerSession().getForwardScanning(),
                                                                                       null);
            } else
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(
                               tc,
                               "attachToLocalDurableSubscription",
                               "SIDurableSubscriptionNotFoundException");
                throw new SIDurableSubscriptionNotFoundException(
                                nls.getFormattedMessage(
                                                        "SUBSCRIPTION_DOESNT_EXIST_ERROR_CWSIP0146",
                                                        new Object[] {
                                                                      subState.getSubscriberID(),
                                                                      _messageProcessor.getMessagingEngineName() },
                                                        null));
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "attachToLocalDurableSubscription", data);

        return data;
    }