Can not store a new token in the keyring
-
Hi there, I’m playing around with the keyring plugin trying to pull out data from a server that requires authorization oAuth.
This is my code:class Keyring_Service_Mendeley extends Keyring_Service_OAuth1 { const NAME = 'mendeley'; const LABEL = 'Mendeley'; var $authorization_header; var $authorization_realm; function __construct() { parent::__construct(); // Enable "basic" UI for entering key/secret add_action( 'keyring_mendeley_manage_ui', array( $this, 'basic_ui' ) ); //$this->authorization_header = true; $this->authorization_realm = "https://www.mendeley.com/oapi/"; $this->set_endpoint( 'request_token', 'https://www.mendeley.com/oauth/request_token/', 'GET' ); $this->set_endpoint( 'authorize', 'https://www.mendeley.com/oauth/authorize/', 'GET'); $this->set_endpoint( 'access_token', 'https://www.mendeley.com/oauth/access_token/', 'GET'); if ( defined( 'KEYRING__MENDELEY_KEY' ) && defined( 'KEYRING__MENDELEY_SECRET' ) ) { $this->key = KEYRING__MENDELEY_KEY; $this->secret = KEYRING__MENDELEY_SECRET; } else if ( $creds = $this->get_credentials() ) { $this->key = $creds['key']; $this->secret = $creds['secret']; } $this->consumer = new OAuthConsumer( $this->key, $this->secret, $this->callback_url ); $this->signature_method = new OAuthSignatureMethod_HMAC_SHA1; $this->requires_token( true ); } function parse_response( $response ) { return json_decode( $response ); // Get user profile information } function build_token_meta( $token ) { // Set the token so that we can make requests using it $this->set_token( new Keyring_Token( 'linkedin', new OAuthToken( $token['oauth_token'], $token['oauth_token_secret'] ), array( 'type' => 'access', ) ) ); // Get user profile information $response = $this->request( "https://api.mendeley.com/oapi/profiles/info/me/" ); if ( Keyring_Util::is_error( $response ) ) return array(); $this->person = $response; $meta = array( 'user_id' => $this->person->id, 'name' => $this->person->formattedName, ); return $meta; } function get_display( Keyring_Token $token ) { return $token->get_meta( 'name' ); } } add_action( 'keyring_load_services', array( 'Keyring_Service_Mendeley', 'init' ) );
I can not set a new token. It just doesn’t work.
Thanks for your help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Can not store a new token in the keyring’ is closed to new replies.