# “Access to the path '…/OAuthSettings.txt.lock' is denied.” error when using OAuth data sources

**URL:** <https://community.cdata.com/t/access-to-the-path-oauthsettings-txt-lock-is-denied-error-when-using-oauth-data-sources/452>\
**Category:** Editions\
**Tags:** article, oauth, jdbc, permissions, ado.net, oauthsettingslocation\
**Created:** [October 10, 2023, 9:27pm UTC](https://community.cdata.com/t/access-to-the-path-oauthsettings-txt-lock-is-denied-error-when-using-oauth-data-sources/452 "2023-10-10T21:27:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brajan\_Hasmeta](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@Brajan\_Hasmeta](https://community.cdata.com/u/Brajan_Hasmeta)\
**Post date:** [October 10, 2023, 9:27pm UTC](https://community.cdata.com/t/access-to-the-path-oauthsettings-txt-lock-is-denied-error-when-using-oauth-data-sources/452/1 "2023-10-10T21:27:44Z")

</div>

To demonstrate the problem, I will be utilizing CData Google Analytics JDBC and [ADO.NET](http://ADO.NET) Drivers as examples. However, it is important to note that this error can occur in any OAuth data source.

When trying to authenticate with OAuth, one of the most important things of the whole OAuth flow is the **OAuthSettings** file.

When the driver redirects you to the web browser to initiate OAuth and you grant permissions, the driver sends a request in the Data Source’s API with the Authorization Code retrieved from the web URL to obtain an Access Token and a Refresh Token. If these values weren’t saved somewhere, the driver would have to redirect to the web browser each time you made a connection, which isn’t very practical. This is the reason why the **OAuthSettings** file holds a major importance in OAuth flow.

After retrieving the OAuth tokens, the driver creates an _OAuthSettings.txt_ file in the path of “[_OAuthSettingsLocation_](https://cdn.cdata.com/help/DAJ/jdbc/RSBGoogleAnalytics_p_OAuthSettingsLocation.htm)” connection property. In JDBC and [ADO.NET](http://ADO.NET) (Windows platform), by default, this location is:

_“%APPDATA%\CData\GoogleAnalytics Data Provider\OAuthSettings.txt__”_\*\*

For the driver to be able to create this **.txt** file and write/re-write it (in case of refreshing the Access Token), the user needs to have full-access permission to this file path.

The default path that is set in the _ **OAuthSettingsLocation** _ property has full-access permissions for the current user. However, there might be cases where these permissions are altered, and the user **doesn’t**  **have read/write permissions** , or it could be that the user has set a custom _ **OAuthSettingsLocation** _ path such as:

_“C:\Users\BrajanHasmeta\OAuth\OAuthSettings.txt”,_

and this custom path doesn’t have **read/write** permissions for the user who is accessing it.

In these cases, the driver throws an **“_Access is denied__”_** error.

In JDBC, the error would look like the following:

“_Test connection failed. Error: Access is denied_”

 ![c5d825b2-d540-4eda-b05a-2d73ec1d06ba.png](https://us1.discourse-cdn.com/cdata/original/1X/62f60cac171ebbe842c83c23aad0deececadaef2.png)

In [ADO.NET](http://ADO.NET), the error is more specific, and it explains in which path the access is denied:

_“Access to the path ‘C:\Users\BrajanHasmeta\AppData\Roaming\CData\GoogleAnalytics Data Provider\OAuthSettings.txt.lock’ is denied.”_

 ![ca61703f-b8e5-4f2c-8bbb-a8caab166154.png](https://us1.discourse-cdn.com/cdata/original/2X/3/37a8ab151a66519c93b8e90a06368c6607e7a747.png)

There are two ways to fix this problem:

1. The easiest one is to set the _ **OAuthSettingsLocation** _ property to a Public path, such as:

_ **“C:\Users\Public\Documents\OAuthSettings.txt”** _

**NOTE** : The Public Documents folder can normally be accessed by all users on the machine, however, it doesn’t mean that it can’t be altered. That said, if the Public path does not work, you may need to locate a path that guarantees full-access permissions.

2. The second way is by **modifying the permissions** of your folder that contains the OAuthSettings.txt file. To do so, open “ **File Explorer** ”, and go to the file path that is specified in the _ **OAuthSettingsLocation** _ property. **Right-click** the folder that contains your OAuthSettings.txt file \>\> Click _Properties_ \>\> Go to _ **Security** _. After clicking _ **Edit** ,_ the “ **Permissions** ” tab will show up. After this, select the user you want to grant access to, and check the _ **Allow** _ box for the “ **Full Control** ” permission level. Then, click **Apply** \>\> click **OK** :

 ![99a20fcb-840e-482a-8808-a0316d1a8fbe.png](https://us1.discourse-cdn.com/cdata/original/2X/5/54fbfa268a6f6e271ca73e1fa51c84e3822ac4b9.png)
