Authentication Error : Token is not valid

AuthenticationError: Your authentication token is not from a valid issuer.

I am keep getting authentication error. Token is not working anymore within example notebook provided in deeplearning.ai tutorial.

---------------------------------------------------------------------------
AuthenticationError                       Traceback (most recent call last)
Cell In[3], line 1
----> 1 response = get_completion("What is the capital of France?")

Cell In[2], line 3, in get_completion(prompt, model)
      1 def get_completion(prompt, model="gpt-3.5-turbo"):
      2     messages = [{"role": "user", "content": prompt}]
----> 3     response = openai.ChatCompletion.create(
      4         model=model,
      5         messages=messages,
      6         temperature=0,
      7     )
      8     return response.choices[0].message["content"]

File /usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py:25, in ChatCompletion.create(cls, *args, **kwargs)
     23 while True:
     24     try:
---> 25         return super().create(*args, **kwargs)
     26     except TryAgain as e:
     27         if timeout is not None and time.time() > start + timeout:

File /usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py:153, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
    127 @classmethod
    128 def create(
    129     cls,
   (...)
    136     **params,
    137 ):
    138     (
    139         deployment_id,
    140         engine,
   (...)
    150         api_key, api_base, api_type, api_version, organization, **params
    151     )
--> 153     response, _, api_key = requestor.request(
    154         "post",
    155         url,
    156         params=params,
    157         headers=headers,
    158         stream=stream,
    159         request_id=request_id,
    160         request_timeout=request_timeout,
    161     )
    163     if stream:
    164         # must be an iterator
    165         assert not isinstance(response, OpenAIResponse)

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:230, in APIRequestor.request(self, method, url, params, headers, files, stream, request_id, request_timeout)
    209 def request(
    210     self,
    211     method,
   (...)
    218     request_timeout: Optional[Union[float, Tuple[float, float]]] = None,
    219 ) -> Tuple[Union[OpenAIResponse, Iterator[OpenAIResponse]], bool, str]:
    220     result = self.request_raw(
    221         method.lower(),
    222         url,
   (...)
    228         request_timeout=request_timeout,
    229     )
--> 230     resp, got_stream = self._interpret_response(result, stream)
    231     return resp, got_stream, self.api_key

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:624, in APIRequestor._interpret_response(self, result, stream)
    616     return (
    617         self._interpret_response_line(
    618             line, result.status_code, result.headers, stream=True
    619         )
    620         for line in parse_stream(result.iter_lines())
    621     ), True
    622 else:
    623     return (
--> 624         self._interpret_response_line(
    625             result.content.decode("utf-8"),
    626             result.status_code,
    627             result.headers,
    628             stream=False,
    629         ),
    630         False,
    631     )

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:687, in APIRequestor._interpret_response_line(self, rbody, rcode, rheaders, stream)
    685 stream_error = stream and "error" in resp.data
    686 if stream_error or not 200 <= rcode < 300:
--> 687     raise self.handle_error_response(
    688         rbody, rcode, resp.data, rheaders, stream_error=stream_error
    689     )
    690 return resp

AuthenticationError: Your authentication token is not from a valid issuer.

I am getting the same error on the ChatGPT prompt engineering course as well currently but those nbs worked for me earlier so seems like something is broken currently with the authentication!!

Last time, it worked for me, was last thursday or friday when I was taking ChatGPT for Prompt Engineering Course and it stopped working today. I think either api token is revoked/not valid or there is some limitation/cap

Also running into the same issue today while it worked a week or two ago.

+1 This worked for me till yesterday, but I’m seeing the same error

Confirmed. I just started this course today and I got the same error.

I have just completed half of the ChatGPT Prompt Engineering for Developers Course and out of nowhere it started giving me the same error which says the Authentication token is not from valid issuer. I don’t know if it is a bug or some usage limit. Can anyone have what is causing this problem?

---------------------------------------------------------------------------
AuthenticationError                       Traceback (most recent call last)
Cell In[28], line 7
      1 prompt = f"""
      2 What is the sentiment of the following product review, 
      3 which is delimited with triple backticks?
      4 
      5 Review text: '''{lamp_review}'''
      6 """
----> 7 response = get_completion(prompt)
      8 print(response)

Cell In[26], line 3, in get_completion(prompt, model)
      1 def get_completion(prompt, model="gpt-3.5-turbo"):
      2     messages = [{"role": "user", "content": prompt}]
----> 3     response = openai.ChatCompletion.create(
      4         model=model,
      5         messages=messages,
      6         temperature=0, # this is the degree of randomness of the model's output
      7     )
      8     return response.choices[0].message["content"]

File /usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py:25, in ChatCompletion.create(cls, *args, **kwargs)
     23 while True:
     24     try:
---> 25         return super().create(*args, **kwargs)
     26     except TryAgain as e:
     27         if timeout is not None and time.time() > start + timeout:

File /usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py:153, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
    127 @classmethod
    128 def create(
    129     cls,
   (...)
    136     **params,
    137 ):
    138     (
    139         deployment_id,
    140         engine,
   (...)
    150         api_key, api_base, api_type, api_version, organization, **params
    151     )
--> 153     response, _, api_key = requestor.request(
    154         "post",
    155         url,
    156         params=params,
    157         headers=headers,
    158         stream=stream,
    159         request_id=request_id,
    160         request_timeout=request_timeout,
    161     )
    163     if stream:
    164         # must be an iterator
    165         assert not isinstance(response, OpenAIResponse)

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:226, in APIRequestor.request(self, method, url, params, headers, files, stream, request_id, request_timeout)
    205 def request(
    206     self,
    207     method,
   (...)
    214     request_timeout: Optional[Union[float, Tuple[float, float]]] = None,
    215 ) -> Tuple[Union[OpenAIResponse, Iterator[OpenAIResponse]], bool, str]:
    216     result = self.request_raw(
    217         method.lower(),
    218         url,
   (...)
    224         request_timeout=request_timeout,
    225     )
--> 226     resp, got_stream = self._interpret_response(result, stream)
    227     return resp, got_stream, self.api_key

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:620, in APIRequestor._interpret_response(self, result, stream)
    612     return (
    613         self._interpret_response_line(
    614             line, result.status_code, result.headers, stream=True
    615         )
    616         for line in parse_stream(result.iter_lines())
    617     ), True
    618 else:
    619     return (
--> 620         self._interpret_response_line(
    621             result.content.decode("utf-8"),
    622             result.status_code,
    623             result.headers,
    624             stream=False,
    625         ),
    626         False,
    627     )

File /usr/local/lib/python3.9/site-packages/openai/api_requestor.py:683, in APIRequestor._interpret_response_line(self, rbody, rcode, rheaders, stream)
    681 stream_error = stream and "error" in resp.data
    682 if stream_error or not 200 <= rcode < 300:
--> 683     raise self.handle_error_response(
    684         rbody, rcode, resp.data, rheaders, stream_error=stream_error
    685     )
    686 return resp

AuthenticationError: Your authentication token is not from a valid issuer.

Never Mind, I think It was a bug, because it started working after sometime. :upside_down_face:

I was getting the same error. But when I tried after some time (I had also refreshed the page), it got automatically solve.