Skip to content

Component functions

tenebrousedge edited this page Dec 26, 2012 · 1 revision

If you are using the provided authorization object, there is no need to explicitly direct the user to an authorization action; they will be redirected to the OAuth provider after an authorization failure. You must, however, implement an action somewhere in your application to handle the callback from the OAuth provider. For those that missed the links on what actually happens in this process, now is a good time to review that information:

If you do not need any special behavior for any step in this process, define a callback method as follows:

<?php
	class MyApiController extends AppController {
		function callback(){
			$this->Oauth->callback('myApi');
		}
	}

The Oauth component uses a Session variable 'Oauth.redirect' to determine if users should be redirected elsewhere after a successful authorization. It sets this variable to the value of $this->controller->request->here when it begins to handle an Authorization failure, so hopefully after the user gets done authorizing your application's use of the Remote API on their behalf, they end up doing what they originally wanted to do on your site. If 'Oauth.redirect' is not set, the callback function will return an array containing the new access token.