Headless Machines
Using OAuth on a Headless Machine
To create Microsoft Excel Online data sources on headless servers or other machines on which the provider cannot open a browser, you need to authenticate from another machine. Authentication is a two-step process.
- Instead of installing the provider on another machine, you can follow the steps below to obtain the OAuthVerifier value. Or, you can install the provider on another machine and transfer the OAuth authentication values, after you authenticate through the usual browser-based flow.
- You can then configure the provider to automatically refresh the access token from the headless machine.
Using the Credentials for a Custom OAuth App
Create a Custom OAuth App
See Creating a Custom OAuth App for a procedure. You can then follow the procedures below to authenticate and connect to data.
Obtain a Verifier Code
On the headless machine, set one the following properties groups depending on the authentication type:
- Authenticating using a Client Secret
- InitiateOAuth: Set this to OFF.
- OAuthClientId: Set this to the App Id in your app settings.
- OAuthClientSecret: Set this to the App Secret in your app settings.
- Authenticating using a Certificate
- InitiateOAuth: Set this to OFF.
- OAuthClientId: Set this to the App Id in your app settings.
- OAuthJWTCert: Set this to the JWT Certificate store.
- OAuthJWTCertType: Set this to the type of the certificate store specified by OAuthJWTCert.
You can then follow the steps below to authenticate from another machine and obtain the OAuthVerifier connection property.
- Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app settings.
- Open the returned URL in a browser. Log in and grant permissions to the provider. You are then redirected to the callback URL. The webpage will state that the site could not be reached.
- Inspect the URL of the this site page and find the code value. It will be present in the URL in the form code=XXXXXX (terminated with &, which denotes the next URL parameter) The value after the "code=" is the verifier code.
- Save the value of the verifier code. You will set this in the OAuthVerifier connection property.
On the headless machine, set the one of the following connection properties groups depending on the authentication type to obtain the OAuth authentication values:
- OAuthClientId: Set this to the consumer key in your app settings.
- OAuthClientSecret: Set this to the consumer secret in your app settings.
- OAuthVerifier: Set this to the verifier code.
- OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified file.
- InitiateOAuth: Set this to REFRESH.
Connect to Data
After the OAuth settings file is generated, set the following properties to connect to data:
- OAuthSettingsLocation: Set this to the file containing the encrypted OAuth authentication values. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.
- InitiateOAuth: Set this to REFRESH.
Transfer OAuth Settings
Follow the steps below to install the provider on another machine, authenticate, and then transfer the resulting OAuth values.
On a second machine, install the provider and connect with the one of the following properties groups depending on the authentication type:
- Authenticating using a Client Secret
- OAuthSettingsLocation: Set this to a writable text file.
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthClientSecret: Set this to the Client Secret in your app settings.
- CallbackURL: Set this to the Callback URL in your app settings.
- Authenticating using a Certificate
- OAuthSettingsLocation: Set this to a writable text file.
- InitiateOAuth: Set this to GETANDREFRESH.
- OAuthClientId: Set this to the Client Id in your app settings.
- OAuthJWTCert: Set this to the JWT Certificate store.
- OAuthJWTCertType: Set this to the type of the certificate store specified by OAuthJWTCert.
- CallbackURL: Set this to the Callback URL in your app settings.
Test the connection to authenticate. The resulting authentication values are written, encrypted, to the path specified by OAuthSettingsLocation. Once you have successfully tested the connection, copy the OAuth settings file to your headless machine. On the headless machine, set the following connection properties to connect to data:
- InitiateOAuth: Set this to REFRESH.
- OAuthSettingsLocation: Set this to the path to your OAuth settings file. Make sure this file gives read and write permissions to the provider to enable the automatic refreshing of the access token.