AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AuthObserverInterface.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
19 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_AUTHOBSERVERINTERFACE_H_
20 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_AUTHOBSERVERINTERFACE_H_
21 
22 #include <ostream>
23 
24 namespace alexaClientSDK {
25 namespace avsCommon {
26 namespace sdkInterfaces {
27 
32 public:
34  enum class State {
38  REFRESHED,
40  EXPIRED,
45  };
46 
48  enum class Error {
50  SUCCESS,
72  SLOW_DOWN,
77  };
78 
80  struct FullState {
83 
86 
88  FullState();
89 
96  FullState(
99  };
100 
104  virtual ~AuthObserverInterface() = default;
105 
115  virtual void onAuthStateChange(State newState, Error error) = 0;
116 };
117 
121 }
122 
126  state = pState;
127  error = pError;
128 }
129 
139  return lhs.state == rhs.state && lhs.error == rhs.error;
140 }
141 
149 inline std::ostream& operator<<(std::ostream& stream, const AuthObserverInterface::State& state) {
150  switch (state) {
152  return stream << "UNINITIALIZED";
154  return stream << "REFRESHED";
156  return stream << "EXPIRED";
158  return stream << "UNRECOVERABLE_ERROR";
160  return stream << "AUTHORIZING";
161  }
162  return stream << "Unknown AuthObserverInterface::State!: " << state;
163 }
164 
172 inline std::ostream& operator<<(std::ostream& stream, const AuthObserverInterface::Error& error) {
173  switch (error) {
175  return stream << "SUCCESS";
177  return stream << "UNKNOWN_ERROR";
179  return stream << "AUTHORIZATION_FAILED";
181  return stream << "UNAUTHORIZED_CLIENT";
183  return stream << "SERVER_ERROR";
185  return stream << "INVALID_REQUEST";
187  return stream << "INVALID_VALUE";
189  return stream << "AUTHORIZATION_EXPIRED";
191  return stream << "UNSUPPORTED_GRANT_TYPE";
193  return stream << "INVALID_CODE_PAIR";
195  return stream << "AUTHORIZATION_PENDING";
197  return stream << "SLOW_DOWN";
199  return stream << "INTERNAL_ERROR";
201  return stream << "INVALID_CBL_CLIENT_ID";
202  }
203  return stream << "Unknown AuthObserverInterface::Error!: " << error;
204 }
205 
206 } // namespace sdkInterfaces
207 } // namespace avsCommon
208 } // namespace alexaClientSDK
209 
210 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_AUTHOBSERVERINTERFACE_H_
alexaClientSDK::avsCommon::sdkInterfaces::operator<<
std::ostream & operator<<(std::ostream &stream, const AudioInputProcessorObserverInterface::State &state)
Definition: AudioInputProcessorObserverInterface.h:86
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::INVALID_CBL_CLIENT_ID
@ INVALID_CBL_CLIENT_ID
Client ID not valid for use with code based linking.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::~AuthObserverInterface
virtual ~AuthObserverInterface()=default
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error
Error
The enum Error encodes possible errors which may occur when changing state.
Definition: AuthObserverInterface.h:48
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::FullState::error
avsCommon::sdkInterfaces::AuthObserverInterface::Error error
The error.
Definition: AuthObserverInterface.h:85
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::FullState::FullState
FullState()
Constructor.
Definition: AuthObserverInterface.h:118
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::onAuthStateChange
virtual void onAuthStateChange(State newState, Error error)=0
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::SLOW_DOWN
@ SLOW_DOWN
Client should slow down in the rate of requests polling for an access token.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::INVALID_VALUE
@ INVALID_VALUE
One of the values in the request was invalid.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::INVALID_REQUEST
@ INVALID_REQUEST
The request is missing a required parameter, has an invalid value, or is otherwise improperly formed.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::UNKNOWN_ERROR
@ UNKNOWN_ERROR
An unknown body containing no error field has been encountered.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::State::AUTHORIZING
@ AUTHORIZING
Currently in the process of authorizing, such as requesting or refreshing a token.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::SERVER_ERROR
@ SERVER_ERROR
The server encountered a runtime error.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::AUTHORIZATION_EXPIRED
@ AUTHORIZATION_EXPIRED
The authorization code is invalid, expired, revoked, or was issued to a different client.
alexaClientSDK::avsCommon::sdkInterfaces::operator==
bool operator==(const AuthObserverInterface::FullState &lhs, const AuthObserverInterface::FullState &rhs)
Definition: AuthObserverInterface.h:138
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::State::UNRECOVERABLE_ERROR
@ UNRECOVERABLE_ERROR
Authorization failed in a manner that cannot be corrected by retry.
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::State::UNINITIALIZED
@ UNINITIALIZED
Authorization not yet acquired.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::SUCCESS
@ SUCCESS
Success.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface
Definition: AuthObserverInterface.h:31
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::FullState::state
avsCommon::sdkInterfaces::AuthObserverInterface::State state
The state.
Definition: AuthObserverInterface.h:82
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::INTERNAL_ERROR
@ INTERNAL_ERROR
Internal error in client code.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::State::REFRESHED
@ REFRESHED
Authorization has been refreshed.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::State::EXPIRED
@ EXPIRED
Authorization has expired.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::UNAUTHORIZED_CLIENT
@ UNAUTHORIZED_CLIENT
The client is not authorized to use authorization codes.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::UNSUPPORTED_GRANT_TYPE
@ UNSUPPORTED_GRANT_TYPE
The client specified the wrong token type.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::State
State
The enum State describes the state of authorization.
Definition: AuthObserverInterface.h:34
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::AUTHORIZATION_FAILED
@ AUTHORIZATION_FAILED
The client authorization failed.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::AUTHORIZATION_PENDING
@ AUTHORIZATION_PENDING
Waiting for user to authorize the specified code pair.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::Error::INVALID_CODE_PAIR
@ INVALID_CODE_PAIR
Invalid code pair provided in Code-based linking token request.
alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface::FullState
An aggregated structure to simplify working with State and Error.
Definition: AuthObserverInterface.h:80

AlexaClientSDK 1.26.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0