Skip to content

Instantly share code, notes, and snippets.

@paluchas
Created June 26, 2017 14:17
Show Gist options
  • Save paluchas/9418142d49051a2a99718fa051e23ea1 to your computer and use it in GitHub Desktop.
Save paluchas/9418142d49051a2a99718fa051e23ea1 to your computer and use it in GitHub Desktop.
Our PHP code snippet used to set up ORCID API scopes as well as customise an OAuth form.
/**
* Generic connector to route to create initiate Orcid Auth process.
* While we are only using the app to read data (in the intial phase)
* we need all the scopes: /read-limited, /activities/update and /person/update.
*
* @return redirect to authorization URL
*/
public function connect()
{
$this->oauth->setClientId(config('orcid.client_id'))
->setScope('/read-limited /activities/update /person/update')
->setGivenNames(\App\Orcid::getGivenName())
->setFamilyNames(\App\Orcid::getFamilyName())
->setEmail(\App\Orcid::getEmailAddress())
->setRedirectUri(config('orcid.redirect')."/authenticated");
return redirect($this->oauth->getAuthorizationUrl());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment