Type : CREATION_INTERNE
Le script ne lit pas de données pour analyse. Son but est de générer un fichier de configuration (`token.json`) contenant les jetons d'authentification. Il dépend de fichiers de configuration SAS externes (`onedrive_config.sas`) et de macros (`onedrive_macros.sas`) qui doivent exister au chemin spécifié.
| 1 | /* |
| 2 | This file contains steps that you perform just once to |
| 3 | set up a new project. You'll use these steps to get an |
| 4 | access code and your initial authentication tokens. |
| 5 | |
| 6 | You might need to repeat this step later if your |
| 7 | Microsoft Office 365 credentials change (including password) |
| 8 | or if the tokens are revoked by using another method. |
| 9 | |
| 10 | */ |
| 11 | %let config_root=/folders/myfolders/onedrive; |
| 12 | |
| 13 | %include "&config_root./onedrive_config.sas"; |
| 14 | %include "&config_root./onedrive_macros.sas"; |
| 15 | |
| 16 | /* |
| 17 | Our json file that contains the oauth token information |
| 18 | */ |
| 19 | filename token "&config_root./token.json"; |
| 1 | /* Do these steps JUST ONCE, interactively, |
| 2 | for your application and user account. |
| 3 | |
| 4 | Get the code from the URL in the browser and set it below |
| 5 | as the value of auth_code. |
| 6 | |
| 7 | The authorization code is going to be a LONG character value. |
| 8 | */ |
| 9 | |
| 10 | /* Run this line to build the authorization URL */ |
| 11 | %let authorize_url=https://login.microsoftonline.com/&tenant_id./oauth2/authorize?client_id=&client_id.%nrstr(&response_type)=code%nrstr(&redirect_uri)=&redirect_uri.%nrstr(&resource)=&resource.; |
| 12 | options nosource; |
| 13 | %put Paste this URL into your web browser:; |
| 14 | %put -- START -------; |
| 15 | %put &authorize_url; |
| 16 | %put ---END ---------; |
| 17 | options SOURCE; |
| 1 | /* |
| 2 | Copy the value of the authorize_url into a web browser. |
| 3 | Log into your OneDrive account as necessary. |
| 4 | The browser will redirect to a new address. |
| 5 | Copy the auth_code value from that address into the following |
| 6 | macro variable. Then run the next two lines (including %get_token macro). |
| 7 | |
| 8 | Note: this code can be quite long -- 700+ characters. |
| 9 | */ |
| 10 | %let auth_code=; |
| 11 | |
| 12 | /* |
| 13 | Now that we have an authorization code we can get the access token |
| 14 | This step will write the tokens.json file that we can use in our |
| 15 | production programs. |
| 16 | */ |
| 17 | %get_token(&client_id.,&auth_code,&resource.,token,tenant=&tenant_id,debug=3); |