• Steve P (UK)

    (@stevepalmeratwordpress)


    Hi Everyone

    I’m new to WordPress but am learning pretty fast, having just moved all my blogs from Blogger to WordPress. I’ve since added plenty of plugins and yours is the latest. I can see it’s very powerful and I’d like to get it working – but I can’t.

    I’ve been through the setup process, but If I try and add a Google Album, it pops up an error message pointing back to the setup/authentication screen – I suspect I have created an error here, somewhere.

    I get all the way through the process (Google Client ID and the Google Secret are all OK) but when it comes to the token stage, and try and get it, the token is ‘undefined’
    is that normal? Is that what is stopping it functioning?

    The screen then suggests that I use ‘Google Photos Refresh Token Getter’, but I am not seeing that option anywhere.

    Does any of this make sense? Is there any other data I can provide you with to get your excellent plugin working?

    I tried ‘re-authenticating’ but I still get ‘undefined’ for the token – and the plugin is is still unable to find any of my Albums.

    I’d appreciate any help.

    Thanks

    Steve

Viewing 15 replies - 31 through 45 (of 78 total)
  • Plugin Author Sayontan Sinha

    (@sayontan)

    Interesting. I am only seeing the “print” happen once.

    Essentially this is what the original code is:

    if (!empty($token)) {
    	$this->access_token = $token['oauth_token'];
    }

    It should become:

    print_r($photonic_authentication);
    print_r($token);
    
    if (!empty($token)) {
    	$this->access_token = $token['oauth_token'];
    }
    
    print_r($photonic_authentication);
    print_r($token);

    What did you have it as?

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    Done! Thanks for clarifying…
    ??

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    Now I’m getitng

    Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION) in /homepages/0/d770584787/htdocs/app770584978/wp-content/plugins/photonic/extensions/Photonic_OAuth2_Processor.php on line 185

    and the page won’t load

    Plugin Author Sayontan Sinha

    (@sayontan)

    Hmm … do ensure that you copy the code exactly as I have provided it on the forum (not from email).

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    I think I’ve screwed up the php file somehow. If I remove the two blocks of code you suggested, it still doesn’t load

    Plugin Author Sayontan Sinha

    (@sayontan)

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    Phew! Thanks for that!

    OK. I’ve replaced the damaged php file and added in your lines of code.

    My site now won’t load. Here is the text I pasted…

    		}
    
    		print_r($photonic_authentication);
    		print_r($token);
    
    		if (!empty($token)) {
    			$this->access_token = $token['oauth_token'];
    		}
    
    		print_r($photonic_authentication);
    		print_r($token);
    

    What did I do wrong?

    Plugin Author Sayontan Sinha

    (@sayontan)

    Did you add that curly brace (the }) at the top? That will certainly cause an error.

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    OK. I’ve taken out (what I think) are the additional braces. It now looks like this… But the site still won’t load

    }
    		else if (isset($photonic_authentication[$this->provider])) {
    			$token = $photonic_authentication[$this->provider];
    			if (isset($token)) {
    				if ($this->is_token_expired($token)) {
    					$token = $this->get_access_token_from_refresh($refresh_token, true);
    		print_r($photonic_authentication);
    		print_r($token);
    
    		if (!empty($token)) {
    			$this->access_token = $token['oauth_token'];
    		}
    
    		print_r($photonic_authentication);
    		print_r($token);
    
    	function get_access_token_from_refresh($refresh_token, $save) {
    

    (Sorry, I’m a bit out of my comfort zone)

    Steve

    Plugin Author Sayontan Sinha

    (@sayontan)

    Sorry, the braces seem to be a bit out of whack with what you have. I would suggest doing the following:

    1. Replace the file with the original, and save. Try reloading your site – it will load now.
    2. Find this block of code:
      if (!empty($token)) {
      	$this->access_token = $token['oauth_token'];
      }
    3. Before the if (!empty($token)) { put this in exactly as follows:
      print_r($photonic_authentication);
      print_r($token);

      Any extra brace, or removed brace will cause your site to break.
      After you have saved the change, try reloading your site – it should load up without issues, as it was doing when you first put in this change.

    4. Now, look at this code again:
      if (!empty($token)) {
      	$this->access_token = $token['oauth_token'];
      }
    5. After the line that says }, put this in, again, exactly as follows:
      print_r($photonic_authentication);
      print_r($token);

      Any extra brace, or removed brace will cause your site to break.
      After you have saved the change, try reloading your site – it should load up now.

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    Thanks for your patience Sayontan!

    Extra lines of code added. Site loading OK.

    Yay!

    I guess that should give you what you need in terms of error codes at
    https://stevepalmertheblogger.com/2019/02/05/test-photonic/

    Steve

    Plugin Author Sayontan Sinha

    (@sayontan)

    Unfortunately I will need some more edits.

    1. First, replace the file you had with the original
    2. Now look for this code:
      public function perform_back_end_authentication($refresh_token) {
      	$photonic_authentication = get_option('photonic_authentication');
      	if (!isset($photonic_authentication)) {
      		$photonic_authentication = array();
      	}
      
      	if (!isset($photonic_authentication[$this->provider]) && !empty($refresh_token)) {
      		$token = $this->get_access_token_from_refresh($refresh_token, true);
      	}
      	else if (isset($photonic_authentication[$this->provider])) {
      		$token = $photonic_authentication[$this->provider];
      		if (isset($token)) {
      			if ($this->is_token_expired($token)) {
      				$token = $this->get_access_token_from_refresh($refresh_token, true);
      			}
      		}
      	}
      
      	if (!empty($token)) {
      		$this->access_token = $token['oauth_token'];
      	}
      }
    3. Replace the above with the following verbatim. Please ensure that while replacing, you start from public and end at the }. Specifically note that there is a } on two consecutive lines – you have to replace everything including the second }:
      
      	public function perform_back_end_authentication($refresh_token) {
      		$photonic_authentication = get_option('photonic_authentication');
      		if (!isset($photonic_authentication)) {
      			$photonic_authentication = array();
      		}
      
      		if (!isset($photonic_authentication[$this->provider]) && !empty($refresh_token)) {
      			$token = $this->get_access_token_from_refresh($refresh_token, true);
      print_r('Token did not exist<br/>');
      print_r($token);
      		}
      		else if (isset($photonic_authentication[$this->provider])) {
      			$token = $photonic_authentication[$this->provider];
      print_r('Existing token<br/>');
      print_r($token);
      			if (isset($token)) {
      				if ($this->is_token_expired($token)) {
      					$token = $this->get_access_token_from_refresh($refresh_token, true);
      print_r('Token had expired. New token<br/>');
      print_r($token);
      				}
      				else {
      print_r('Token is valid<br/>');
      					$this->refresh_token_valid = true;
      				}
      			}
      		}
      

    Save now.

    Sorry for putting you through this. At this time I am convinced that there is a plugin conflict, but since you have so many plugins I cannot make a guess about what the offending one may be.

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    Sorry, I pasted the code exactly as you said from the above but I’m now getting

    Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION) in /homepages/0/d770584787/htdocs/app770584978/wp-content/plugins/photonic/extensions/Photonic_OAuth2_Processor.php on line 184

    Shall I post what I pasted back to you. I’ve obviously introduced an error somewhere, but I can’t see where

    ??

    Steve

    Plugin Author Sayontan Sinha

    (@sayontan)

    It’s alright. I have pasted out the entire file for you here: https://pastebin.com/Bje2vkvu. Replace the contents of the whole file with this.

    Thread Starter Steve P (UK)

    (@stevepalmeratwordpress)

    Cheers Sayontan

    All done. Hope it helps!
    ??
    Steve

Viewing 15 replies - 31 through 45 (of 78 total)
  • The topic ‘Failed Authentication (sort of)’ is closed to new replies.