The document discusses OAuth authentication. It describes calling a makeOAuthRequest method to display a login prompt on a mobile device. Once credentials are entered, an accessCodeResult callback provides the response including a temporary access code. A makeWebRequest is then used to request an access token by posting the access code, client secret, client ID, and calling a handleAccessResponse callback to handle the response. If successful, the access token is passed to a handleResponse method.
The document discusses OAuth authentication. It describes calling a makeOAuthRequest method to display a login prompt on a mobile device. Once credentials are entered, an accessCodeResult callback provides the response including a temporary access code. A makeWebRequest is then used to request an access token by posting the access code, client secret, client ID, and calling a handleAccessResponse callback to handle the response. If successful, the access token is passed to a handleResponse method.
The document discusses OAuth authentication. It describes calling a makeOAuthRequest method to display a login prompt on a mobile device. Once credentials are entered, an accessCodeResult callback provides the response including a temporary access code. A makeWebRequest is then used to request an access token by posting the access code, client secret, client ID, and calling a handleAccessResponse callback to handle the response. If successful, the access token is passed to a handleResponse method.
The document discusses OAuth authentication. It describes calling a makeOAuthRequest method to display a login prompt on a mobile device. Once credentials are entered, an accessCodeResult callback provides the response including a temporary access code. A makeWebRequest is then used to request an access token by posting the access code, client secret, client ID, and calling a handleAccessResponse callback to handle the response. If successful, the access token is passed to a handleResponse method.
Earlier, LoginTransaction’s initialize method had set up a call‐
back to handle OAuth messages: Comm.registerForOAuthMessages(method(:accessCodeResult));
The makeOAuthRequest call will cause the login prompt to appear in
Garmin Connect Mobile. Once the user has completed credential entry, the accessCodeResult callback is invoked with the response from the authenticating server, including the temporary access code. At this point, the user is done with the browser on her phone, and your app will use makeWebRequest to request the access token with an HTTP POST request. If this request is successful, it will call our delegate’s handleResponse method with the access token: // Convert the authorization code to the access token function getAccessToken(accessCode) { // Request an access token via POST over HTTPS Comm.makeWebRequest( // URL "https://www.strava.com/oauth/token", // Post parameters { "client_secret"=>$.ClientSecret, "client_id"=>$.ClientId, "code"=>accessCode }, // Options to the request { :method => Comm.HTTP_REQUEST_METHOD_POST }, // Callback to handle response method(:handleAccessResponse) ); }
// Callback to handle receiving the access code
function handleAccessResponse(responseCode, data) { // If we got data back then we were successful. Otherwise // pass the error on to the delegate if( data != null) { _delegate.handleResponse(data); } else { Sys.println("Error in handleAccessResponse"); Sys.println("data = " + data); _delegate.handleError(responseCode); } }