Search code examples
oauth-2.0odbcsnowflake-cloud-data-platformsnowflake-connector

Snowflake ODBC refresh token is not issued


I'm making continuous API calls using snowflake ODBC connection. My access token expires in 10 mins and able to refresh using the refresh token using the below call. But after 90 days my refresh token is getting expired. but this API endpoint

curl -X POST -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" \
    --user "<OAUTH_CLIENT_ID not encoded>:<OAUTH_CLIENT_SECRET>" \
    --data-urlencode "grant_type=refresh_token" \
    --data-urlencode "refresh_token=<refresh_token value>" \
    --data-urlencode "redirect_uri=<OAUTH_REDIRECT_URI not encoded>" \
    <https://mydomain.snowflakecomputing.com/oauth/token-request>

This call returns the access token, only when the refresh token is valid.

This returns 400 bad request and not sending new access and refresh tokens when refresh token is expired.

How do we automatically refresh refresh_token. Is possible or should we repeat the login process and thats the only way?


Solution

  • There is no way to refresh a refresh_token. Once the refresh_token is expired, you will have to start the whole OAuth authorization code flow, this is based on OAuth 2.0 RFC.

    1. Login with your username/password
    2. Get the authorization code
    3. Exchange the access token and refresh token using the authorization code from Step (2) above
    4. When refresh token expired, repeat Step (1)

    Snowflake OAuth is based on OAuth 2.0, you may refer to the RFC here: https://datatracker.ietf.org/doc/html/rfc6749